Proxies + Selenium [duplicate]

一世执手 提交于 2021-01-29 20:23:31

问题


Hi I am fairly new to selenium and I am building a bot that visits a website and enters a term then submits. The issue is that you can only Submit a certain amount of times before the IP address used gets blocked by the server for spam. Is there a way I can implement a proxy rotation every time it opens up a new chrome browser.


回答1:


It would be important to know which browser you are using because the settings differ a bit from browser to browser.

Here is an example of how to use a proxy with Chrome:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

PROXY = "1.111.111.1:8080" #your proxy

chrome_options = WebDriverWait.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)

chrome = webdriver.Chrome(chrome_options=chrome_options)
chrome.get("yourwebsite.com")


来源:https://stackoverflow.com/questions/62237063/proxies-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!