2017-07-11 58 views
-1

我有這個文件的PHP,我想在此運行PHP文件蟒蛇: 但文件PHP阻塞和頁面加載永遠運行文件蟒蛇

<?php 
$result = shell_exec('1.py '); 
echo "Hello world!"; 
?> 

,是我的代碼1.py :

from selenium import webdriver 
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.chrome.options import Options 
from selenium.webdriver.common.keys import Keys 
from selenium.webdriver.common.by import By 
from selenium.webdriver.support import expected_conditions as EC 
import time 

driver = webdriver.Firefox() 
driver.get('https://accounts.google.com/signin/v2/identifier?hl=en& continue=https%3A%2F%2Fmail.google.com%2Fmail&service=mail& flowName=GlifWebSignIn&flowEntry=AddSession') 
time.sleep(1) 
driver.find_element_by_id("identifierId").clear() 
driver.find_element_by_id("identifierId").send_keys('[email protected]') 
driver.find_element_by_css_selector("span.RveJvd.snByac").click() 
time.sleep(1) 
driver.find_element_by_name("password").clear() 
driver.find_element_by_name("password").send_keys('mypassword') 
time.sleep(1) 
driver.find_element_by_css_selector("span.RveJvd.snByac").click() 
time.sleep(3) 
a=driver.title 
#aa= driver.page_source 

if 'Inbox' in a : 
    print('login good') 

else : 
    print('not login') 

,當我在本地主機上運行我的PHP文件/ 1.PHP 被阻斷

$result = shell_exec('1.py '); 

和運行不要

echo "Hello world!"; 

回答

0

嘗試使用下面的PHP:

<?php 
Header("Content-Type: text/plain"); 
error_reporting(E_ALL); 
print shell_exec('1.py'); 
?> 

這樣你可以看到,如果命令打一些其他的問題。

+0

在你共享的代碼中,有兩個「;」關閉回波線 – brotherperes

+0

我的問題是在shell_exec php中阻塞文件python .. – netdevil

+0

你的回答是錯誤的.. – netdevil