1 Star 0 Fork 0

xyislove/python-test

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
selenium模块学习3-无可视化操作即后台操作.py 803 Bytes
一键复制 编辑 原始数据 按行查看 历史
xyislove 提交于 2022-01-03 23:16 . 2022.1.3
from selenium import webdriver
from selenium.webdriver.chrome import options
# 无可视化的相关设置模块
from selenium.webdriver.chrome.options import Options
# 实现规避检测
from selenium.webdriver import ChromeOptions
from time import sleep
# 实现无可视化的相关设置
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
# 实现检测的规避
option=ChromeOptions()
option.add_experimental_option('excludeSwitches',['enable-automation'])
bro = webdriver.Chrome(
executable_path='./python-test/chromedriver', chrome_options=chrome_options,options=option)
# 无可视化 即 无头浏览器
bro.get('https://www.baidu.com')
# 获取网页源码 page_source属性
print(bro.page_source)
sleep(2)
bro.quit()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xyislove/python-test.git
git@gitee.com:xyislove/python-test.git
xyislove
python-test
python-test
master

搜索帮助