#! /usr/bin/python3
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument(’–headless’) #无头启动,无窗口加载
options.add_argument(’–no-sandbox’)
options.add_argument(’–disable-dev-shm-usage’)
options.add_argument(’–disable-gpu’) #不开启gpu加速
options.add_argument(’–hide-scrollbars’) #隐藏滚动条, 应对一些特殊页面
options.add_argument(‘blink-settings=imagesEnabled=false’) #不加载图片, 提升速度
driver = webdriver.Chrome(executable_path = “/usr/bin/chromedriver”, chrome_options = options)
driver.get(“http://www.baidu.com”)
print(driver.page_source)https://win8.com/
无GUI运行脚本
最新推荐文章于 2022-11-24 11:40:03 发布