admin管理员组

文章数量:1530044

 使用selenium 爬取数据,不弹出浏览器,后台运行,需要代码设置下无头参数配置

#浏览器在后台运行,不弹出页面
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
from selenium.webdrivermon.by import By
#准备好参数配置(无头参数配置)
opt=Options()
opt.add_argument("--headless")
opt.add_argument("--disable-gpu")

web = Chrome(options=opt)
web.get("https://www.baidu")
print(web.title)

本文标签: 爬虫无头浏览器设置Pythonselenium