Python 3利用 selenium 的 webdrive 驱动 headless chrome 无界面操作
发布时间:2017-08-15T13:53:14:手机请访问

利用 selenium 的 webdrive 的 chromedriver驱动 chrome60 进行 headless chrome 操作
利用 webdrive 的webdriver.ChromeOptions()方法,添加 headless 相关参数,从而驱动 headless的 chrome
1 2 3 4 5 6 7 8 9 10 11 |
#coding:utf-8 chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') //增加无界面选项 chrome_options.add_argument('--disable-gpu') //如果不加这个选项 有时候定位会出现问题,定位会偏左 driver = webdriver.Chrome(chrome_options=chrome_options,executable_path='/Users/xxxx/driver/chromedriver') driver.get('http://www.168seo.cn') print("当前标题",driver.title) print("当前网址",driver.current_url) |
