selenium无界面chromedriver

Posted When you look into the abyss,

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了selenium无界面chromedriver相关的知识,希望对你有一定的参考价值。

from selenium import webdriver

# 创建chrome参数对象
opt = webdriver.ChromeOptions()

# 把chrome设置成无界面模式,不论windows还是linux都可以,自动适配对应参数
opt.set_headless()

# 创建chrome无界面对象
driver = webdriver.Chrome(options=opt)

# 访问百度
driver.get(https://baidu.com/)

#打印内容
print(driver.page_source)

 

以上是关于selenium无界面chromedriver的主要内容,如果未能解决你的问题,请参考以下文章