webdriver-设置代理
import imaplib import email import requests from selenium import webdriver import time url = "https://mail.google.com/mail/u/1/#search/" # res = requests.get(url, proxies=_proxies) chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') chrome_options.add_argument("--proxy-server=socks5://xxx.xxx:xxx") driver = webdriver.Chrome(options=chrome_options) driver.get(url) driver.find_element_by_css_selector('input[type="email"]').send_keys("xxx@x.com") driver.find_element_by_tag_name("button").click() driver.find_element_by_css_selector('input[type="password"]').send_keys("xxx") driver.find_element_by_xpath('//*[text()="下一步"]').click() driver.save_screenshot("baidu-map.png")