# -*- coding:utf-8 -*-
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import NoSuchElementException
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36")
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.maximize_window()
url = input("输入文档链接,搞快点:")
driver.get(url)
error_str = ""
try :
page_num = driver.find_element_by_xpath("//span[@class='page-count']").text
find_button = driver.find_element_by_xpath("//div[@class='doc-banner-text']")
driver.execute_script("arguments[0].scrollIntoView();", find_button)
button = driver.find_element_by_xpath("//span[@class='moreBtn goBtn']")
button.click()
for i in r
Python + selenium 爬取百度文库Word文本
最新推荐文章于 2025-06-09 16:18:07 发布