gpt4 book ai didi

python - 在使用 Python 启动的脚本中运行 phantomjs/casperjs native 选项

转载 作者:太空宇宙 更新时间:2023-11-03 17:07:57 25 4
gpt4 key购买 nike

CasperJS 版本 1.1.0-beta3,在 OSX 10.10.4 64 位上使用 phantomjs 版本 1.9.8 以及 Python 2.7.6。

您好,感谢您的光临:)

我正在使用 casperjs 运行 JS 脚本,需要使用 Python 脚本启动。

从 bash 启动时,JS 脚本需要 CLI --ignore-ssl-errors=true 才能成功运行。

在 bash 中启动 Python 脚本时,无法使用 --ignore-ssl-errors=true 因为它是 phantomjs/casperjs native 选项。为了解决这个问题,我尝试以编程方式完成此操作,因为根据this question的评论似乎是可能的。 .

阅读后this我在 JS 脚本中使用了以下语法组合​​:

ignoreSslErrors : true;

ignoreSslErrors = true;

ignoreSslErrorsEnabled : true;

ignoreSslErrorsEnabled = true;

启动 JS 脚本时没有起作用,因此当脚本启动时它不会起作用使用 Python 脚本启动。我的语法中遗漏了什么吗?

有没有办法通过Python脚本向phantomjs/casperjs发送 native 命令?具体来说,有没有办法通过Python脚本发送--ignore-ssl-errors=true

如果您需要更多详细信息,请告诉我。

感谢您花时间阅读:)

最佳答案

>在 bash 中启动 Python 脚本时,无法使用 --ignore-ssl-errors=true

事实上,这是很有可能的。这种方法效果很好:

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

关于python - 在使用 Python 启动的脚本中运行 phantomjs/casperjs native 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34420807/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com