python調用遠程chromedriver.exe、selenium抓包方法

本地python示例代碼:
from selenium import webdriver
driver = webdriver.Remote(command_executor='http://192.168.99.10:9515')
driver.get('http://www.cnblogs.com/sherlock-merlin')

服務器端的chromedriver.exe啓動時添加相關啓動參數
chromedriver.exe --whitelisted-ips
或者
chromedriver.exe --whitelisted-ips=192.168.99.20:9515
前者接受全部鏈接,後者接受指定ip鏈接,推薦後者 python


參考信息: web

chromedriver.exe --help

Usage: chromedriver.exe [OPTIONS]

Options
  --port=PORT                     port to listen on
  --adb-port=PORT                 adb server port
  --log-path=FILE                 write server log to file instead of stderr, increases log level to INFO
  --log-level=LEVEL               set log level: ALL, DEBUG, INFO, WARNING, SEVERE, OFF
  --verbose                       log verbosely (equivalent to --log-level=ALL)
  --silent                        log nothing (equivalent to --log-level=OFF)
  --replayable                    (experimental) log verbosely and don't truncate long strings so that the log can be replayed.
  --version                       print the version number and exit
  --url-base                      base URL path prefix for commands, e.g. wd/url
  --whitelisted-ips               comma-separated whitelist of remote IP addresses which are allowed to connect to ChromeDriver
相關文章
相關標籤/搜索