如何在 Tor 实例中使用 Selenium 时更改 IP
我尝试将 Selenium 与 Tor 实例一起使用,但我陷入了 Cloudflare 页面。所以我想更改 IP 地址,直到不需要 Cloudflare 检查为止。我使用下面的函数来更新 Tor 实例,但它不起作用。我导入了 Stem 和其他实用程序。
from stem import Signal
from stem.control import Controller
def renew_connection():
with Controller.from_port(port = 9050) as controller:
controller.authenticate(password="My authentication code")
controller.signal(Signal.NEWNYM)
在这里您可以看到我的首选项
profile.set_preference('network.proxy.type', 1)
profile.set_preference('network.proxy.socks', '127.0.0.1')
profile.set_preference('network.proxy.socks_port', 9050)
profile.set_preference("network.proxy.socks_remote_dns", False)
profile.update_preferences()
当我使用 renew_connection() 函数时,它给出了连接错误。那么您建议如何更新IP地址。
I was trying to use Selenium with a Tor instance but I got caught in the Cloudflare page. So I wanted to change the IP address until it doesn't require Cloudflare check. I used the function below to renew the Tor instance but it didn't work. I imported Stem and other utilities.
from stem import Signal
from stem.control import Controller
def renew_connection():
with Controller.from_port(port = 9050) as controller:
controller.authenticate(password="My authentication code")
controller.signal(Signal.NEWNYM)
Here you can see my preferences
profile.set_preference('network.proxy.type', 1)
profile.set_preference('network.proxy.socks', '127.0.0.1')
profile.set_preference('network.proxy.socks_port', 9050)
profile.set_preference("network.proxy.socks_remote_dns", False)
profile.update_preferences()
When I use the renew_connection() function it gives a connection error. So what do you suggest to renew the IP address.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论