python - python错误 - 无效参数:无法终止退出的进程
问题描述
import sys
link = sys.argv[1]
link = link.replace("%26", "&")
link = link.replace("######", "&")
myProxy = sys.argv[2]
from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy, ProxyType
from selenium.webdriver.firefox.options import Options
proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': myProxy,
'ftpProxy': myProxy,
'sslProxy': myProxy,
'noProxy': ''
})
options = Options()
options.headless = True
options.Proxy = proxy
driver = webdriver.Firefox(options=options)
driver.set_page_load_timeout(10000)
driver.get(link)
s = driver.page_source
print((s.encode("utf-8")))
print (driver.get_cookies())
driver.quit()
这段代码几天前工作得很好,然后我才注意到这条消息:
driver = webdriver.Firefox(options=options)
File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
keep_alive=True)
File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process
我在互联网上搜索了一些解决方案,人们建议将其放入代码中:
options = Options()
options.headless = True
但是我的代码中已经有了这个,所以仍然不能解决我的问题,我还能做些什么吗?我应该以哪种方式找到解决方案的任何帮助或建议会有所帮助?
解决方案
根据代理设置,我认为问题出在 noProxy 选项中
webdriver W3C 说它应该是一个数组
参考:https ://w3c.github.io/webdriver/#proxy
查看您为错误配置提供的选项和值。
推荐阅读
- shell - 从 Ubuntu 端通过 ssh 或串行端口登录到嵌入式 Linux 设备而无需密码
- rotation - 旋转帧缓冲区仅适用于 180° 和 0°
- python - 将 PyQt5 桌面应用程序转换为使用 python 开发的 IOS/MacOS 应用程序
- javascript - 在 Laravel 中使用 pusher 收听消息
- amazon-ec2 - EC2 安全组中的 Bitbucket IP 白名单
- java - 如何使用邮递员休息客户端发送对象以调用 REST 服务,以便它使用正确的方法参数访问下面给定的方法?
- javascript - 在 Liferay 7.2 中将 Web 内容自动保存为草稿
- google-tag-manager - 所有元素单击触发器未触发
- android - 安卓流光盒遥控器使用方法
- android-viewpager - 为什么处于 beta 或 alpha 阶段的 AndroidX 类是最终的?