爬取目标
随便打开一个盗版小说网站,爬取策略和样式都差不多。
例如:https://www.00ksw.com/html/3/3804/
爬取目标,把这个小说,爬取存储到本地的Txt文件
Selenium代码
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
url = "https://www.00ksw.com/html/3/3804/"
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
# 创建Chrome浏览器的配置选项
chrome_options = Options()
chrome_options.add_argument("--headless") # 设置为无头模式
# 初始化Chrome浏览器对象
driver = Chrome(options=chrome_options)
driver.get(url)
# print(driver.page_source)
wait = WebDriverWait(driver, 10)
wait.until(lambda d: "ml_list" in d.page_source)
# print(driver.page_source)