微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

有没有办法直接在运行 Selenium 的 Python 脚本上使用 Torsocks?

如何解决有没有办法直接在运行 Selenium 的 Python 脚本上使用 Torsocks?

我有一个运行 Selenium 的简单 Python 脚本,我尝试使用 Torsocks(像往常一样),就像这样:torsocks python script.py。但是,它因以下错误而失败:

Traceback (most recent call last):
  File "script.py",line 21,in <module>
    browser = webdriver.Firefox(options=options)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/firefox/webdriver.py",line 163,in __init__
    log_path=service_log_path)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/firefox/service.py",line 47,in __init__
    self,executable_path,port=port,log_file=log_file,env=env)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py",line 42,in __init__
    self.port = utils.free_port()
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/utils.py",line 37,in free_port
    free_socket.listen(5)
PermissionError: [Errno 1] Operation not permitted

真的可以像这样使用 Torsocks 吗?

我意识到我可以使用 SOCKS5 代理发送请求,但我想知道它是否可以使用 Torsocks 运行,如果不能,最好能得到解释。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。