如何解决使用Python更改IP地址
我正在尝试构建一个程序,一个程序一个一个地打开Chrome页面。 我正在使用Selenium库。
我的想法是每次打开新页面时都使用不同的IP。
我阅读了有关代理的信息,但无法管理它们。 你能帮我吗?
这是我的代码:
class myClass:
def __init__(self):
self.options = Options()
self.options.add_argument('--allow-running-insecure-content')
self.options.add_argument('--ignore-certificate-errors')
self.driver = webdriver.Chrome('./chromedriver',options = self.options)
def openBrowser(self):
self.chrome.get("http://whatismyipaddress.com")
def closeBrowser(self):
driver = self.driver
driver.close()
driver.quit()
if __name__ == "__main__":
#create object list
object = [myClass(i) for i in range(10)]
for i in range(10):
#open Chrome page
object[i].openBrowser()
# here I want to change IP and then I close the page before opening a new one
#close Chrome page
object[i].closeBrowser()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。