Chrome Headless基础

HeadLess Chrome介绍

创建别名

1
2
3
$ alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
$ alias chrome-canary="/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary"
$ alias chromium="/Applications/Chromium.app/Contents/MacOS/Chromium"

配置chrome driver

Mac

chromedriver文件放在“/usr/local/bin”目录下,然后运行下面的代码

1
2
3
4
5
6
# -*- coding: UTF-8 -*-
from selenium import webdriver

driver = webdriver.Chrome()
base_url = 'https://www.baidu.com'
driver.get(base_url)

参考

Headless Chrome

Puppeteer

坚持原创技术分享,您的支持将鼓励我继续创作!
0%