2015-12-22 32 views
1

CasperJS版本1.1.0-beta3,在OSX 10.10.4 64位上使用phantomjs版本1.9.8以及Python 2.7.6。在Python中啓動的腳本中運行phantomjs/casperjs native選項

您好,感謝回採通過:)

我運行一個JS腳本,使用casperjs,需要用Python腳本啓動。

從bash啓動時,JS腳本需要CLI --ignore-ssl-errors=true才能成功運行。

在bash中啓動Python腳本時,不可能使用--ignore-ssl-errors=true,因爲它是phantomjs/casperjs本機選項。爲了解決這個問題,我嘗試以編程方式進行,因爲根據對this question的評論,似乎可能。

閱讀this後,我用下面的語法組合在我的JS腳本:

ignoreSslErrors : true; 

ignoreSslErrors = true; 

ignoreSslErrorsEnabled : true; 

ignoreSslErrorsEnabled = true; 

無啓動JS腳本的時候工作,所以當腳本 與Python腳本啓動它是行不通的。我的語法錯過了什麼嗎?

有沒有辦法通過Python腳本將本地命令發送到phantomjs/casperjs?具體而言,有沒有辦法通過Python腳本發送--ignore-ssl-errors=true

請讓我知道你是否需要進一步的細節。

感謝您抽出時間來閱讀:)

回答

1

>當啓動在bash的Python腳本,不可能使用--ignore-SSL-錯誤=真

其實,這是很有可能。這種方式工作正常:

import subprocess 
args = ['/usr/local/bin/casperjs', '--ignore-ssl-errors=true', '/path/to/script.js'] 
subprocess.call(args) 
+0

這就像一個魅力工作!謝謝:)我必須升級我的Python遊戲:D – WellWellWell