selenium
网站 | 备注 |
---|---|
selenium官网 | |
chrome、chromedriver、chrome-headless-shell 科学处理 | |
创建新浏览器
sh
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9221
保持命令行运行浏览器,执行一下操作
python
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option('debuggerAddress', '127.0.0.1:9221')
cb = webdriver.Chrome(options=options)
cb.get('https://www.zhihu.com')
print(cb.title)
查看Google浏览器相关信息:
js
chrome://version/
修改Chrome用户存储地址
python
from selenium import webdriver
user_path = 'Users/home/love/Downloads'
options = webdriver.ChromeOptions()
options.add_argument('--user-data-dir={}'.format(user_path))
options.add_experimental_option('debuggerAddress', '127.0.0.1:9221')
cb = webdriver.Chrome(options=options)
cb.get('https://www.zhihu.com')
print(cb.title)