selenium挂ss代理爬取网页内容
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import NoSuchElementException
from bs4 import BeautifulSoup
import time
url = 'https://www.google.com/'
options = Options()
options.headless = True # 无头模式,即不打开浏览器UI
options.binary_location = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe" # chrome安装位置
options.add_argument('--proxy-server=socks5://127.0.0.1:1080') # ss代理
driver = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=options) #chromedriver位置
driver.get(url) # 打开url,会阻塞直到完全打开
html = driver.page_source # 获取html内容
driver.quit()
print(html)