[Python3 crawler] U37_selenium set proxy IP

Sometimes crawl some web pages frequently. The server will block your IP address after discovering that you are a crawler. At this time we can change the proxy ip. Change the proxy IP, different browsers have different implementations. Here takes the Chrome browser as an example to explain:

from selenium import webdriver
 
options = webdriver.ChromeOptions()  # 设置存储浏览器的信息
 
# 添加代理服务器
 
options.add_argument("--proxy-server=http://110.73.2.248:8123")
 
driver_path = r"D:\ProgramApp\chromedriver\chromedriver.exe"
 
driver = webdriver.Chrome(executable_path=driver_path,chrome_options=options)
 
driver.get('http://httpbin.org/ip')

Guess you like

Origin www.cnblogs.com/OliverQin/p/12678131.html