用Python mechanize点击链接后更改IP

2 投票
1 回答
570 浏览
提问于 2025-04-17 22:26

有没有可能用Python写一个脚本,去网站上找一个目标链接,然后点击它,最后再换个IP地址,循环这个过程呢?

有没有一些例子可以参考?

我试着去了解mechanize这个库,但网上没有相关的文档,感谢!

1 个回答

0

如果你手里有一大堆代理可以用来连接,我觉得你完全可以这样做。

proxies = {"proxy_one", "proxy_two", "proxy_three"}
// Not a python guy, this syntax could be completely wrong and I'm sorry, please feel free to edit this

for proxy in proxies:
  req = mechanize.Request("http://www.google.com")
  req.set_proxy(element,"http")
  mechanize.urlopen(req)

撰写回答