python - 每次我发出请求时如何使用 Tor 更改 Selenium 的 IP 地址
问题描述
通过这些代码行,我可以用 Tor 屏蔽我的公共 ip。
def function():
os.system("taskkill /f tor")
torexe = os.popen(r'C:\Users\myuser\Tor Browser\Browser\TorBrowser\Tor\tor.exe')
PROXY = "socks5://localhost:9050"
options = webdriver.ChromeOptions()
options.add_argument('--proxy-server=%s' % PROXY)
driver = webdriver.Chrome(chrome_options=options, executable_path=r"C:/Program Files (x86)/chromedriver.exe")
driver.get("https://www.mikes-marketing-tools.com/whatismyip.php")
我需要每次执行此功能时,公共IP都会更改(使用tor)。我怎么能那样做?
解决方案
推荐阅读
- excel - VBA代码根据单元格范围内的单元格值显示消息
- c# - 配置 NLog 以使用管理标识令牌将日志写入 Azure SQL 服务器
- java - Selenium WebDriver 是同步还是异步打开多个选项卡?
- javascript - 表单后端失效反馈 - 在下次提交之前不再显示
- kerberos - Kerberos + GSSAPI +SASL_PLAINTEXT 的 Mirrormaker 问题
- fortran - 如何将数组传递给一个过程,该过程作为参数传递给使用 Fortran 的另一个过程
- vue.js - 是否可以在不同的 S3 存储桶中设置多个网站,在同一个域下使用 lambda @edge 设置不同的子文件夹?
- powershell - GCloud——Powershell中不等式的过滤器
- clojure - 按公共子字符串对字符串列表进行分组
- wix - WiX 环境组件条件