python小白学习记录 scrapy 结合 selenium 使用自己的chrome浏览器
chrome.exe --remote-debugging-port=9222 --user-data-dir="C:\selenum\AutomationProfile"
此条命令复制到命令行,打开端口为9222的浏览器 ,勿关闭
(此前应先配置环境变量 否则无chrome.exe此命令)
chrome_options = Options() chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222") # 指定chromedriver chrome_driver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe" self.bro = webdriver.Chrome(chrome_driver, chrome_options=chrome_options)
虽然此时路径仍是 chromedriver 因为配置了chrome_options项,故会自动在之前打开的9222端口的浏览器上执行爬虫
这就实现了 控制手工已打开的浏览器
相关推荐
tiankele0 2020-07-29
curiousL 2020-07-18
王练 2020-07-18
Reiki 2020-06-12
xiangxiaojun 2020-09-23
Reiki 2020-08-16
letheashura 2020-08-14
tiankele0 2020-07-18
amei0 2020-07-08
Reiki 2020-07-06
Ronnyxie 2020-07-06
xiangxiaojun 2020-07-05
zhanghaibing00 2020-06-28
xiongyouqiang 2020-06-28
Ronnyxie 2020-06-27
amei0 2020-06-26