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连接,推荐后者


参考信息:

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

posted @ 2018-12-13 17:57  sherlock-merlin  阅读(2695)  评论(0编辑  收藏  举报