当前位置:网站首页>使用webdriver时不显示浏览器运行

使用webdriver时不显示浏览器运行

2022-06-10 02:53:00 盼丨盼

使用webdriver进行爬虫、自动化操作时不显示浏览器运行。

# -*- coding:utf-8 -*-
"""
project: test_test
file: m3u8
author: WangPanPan
create date: 2022/5/30 19:31
"""

from selenium.webdriver.chrome.options import Options
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By

#参考的网页
base_url = 'https://jingyan.baidu.com/article/00a07f38500e2bc3d028dcd3.html'

# 使用webdriver
options = Options()
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)
driver.get(base_url)

three = driver.find_element(By.XPATH,'//*[@id="format-exp"]/div[3]/div/ol/li[3]/div[2]/p').text
print(three)

driver.quit()

原网站

版权声明
本文为[盼丨盼]所创,转载请带上原文链接,感谢
https://blog.csdn.net/u012808186/article/details/125053026