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")

 

posted @ 2021-01-04 17:58  小心走火  阅读(814)  评论(0编辑  收藏  举报