天天看點

Selenium+Chrome認證代理 使用說明

 Selenium+Chrome認證代理不能通過options處理。隻能換個方法使用擴充解決

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

from selenium import webdriver

from common.pubilc import create_proxyauth_extension

proxyauth_plugin_path = create_proxyauth_extension(

    proxy_host="XXXXX.com",

    proxy_port=9020,

    proxy_username="XXXXXXX",

    proxy_password="XXXXXXX"

)

co = webdriver.ChromeOptions()

# co.add_argument("--start-maximized")

co.add_extension(proxyauth_plugin_path)

driver = webdriver.Chrome(executable_path="C:\chromedriver.exe", chrome_options=co)

driver.get("http://ip138.com/")

print(driver.page_source)

options = webdriver.ChromeOptions()

options.add_argument('--proxy-server=http://ip:port')  

driver = webdriver.Chrome(executable_path="C:\chromedriver.exe", chrome_options=0ptions)

阿布雲代理: