当前位置:网站首页>小说抓取实战
小说抓取实战
2022-07-25 04:31:00 【聆听我的召唤,菜鸟进化】
把链接改为这个网站的小说第一章节 35中文
import os
path = '.\chromedriver.exe'
from lxml import etree
import re
from selenium import webdriver
import time
driver = webdriver.Chrome(executable_path=path)
driver.get('https://www.swzw.la/xs/288/288812/56975154.html')
driver.maximize_window()
time.sleep(1)
if not os.path.exists('./texts'):
os.mkdir('./texts')
for i in range(1,50):
source = driver.page_source
tree=etree.HTML(source)
title=tree.xpath('//*[@id="wrapper"]/div[5]/div[2]/div[2]/h1/text()')[0]
text="".join(tree.xpath('//*[@id="content"]//text()'))
file=open(r'D:/爬虫新学习/Day1/texts/{}.txt'.format(i),'w', encoding='utf-8')
info=title+"\t"+text+"\n"
file.write(info)
file.close()
driver.find_element_by_xpath('//*[@id="wrapper"]/div[5]/div[2]/div[2]/div/a[4]').click()
time.sleep(1)
边栏推荐
- Method of setting document comments in idea (graphic version)
- 阿亚的角度思考
- 暗黑王者|ZEGO 低照度图像增强技术解析
- TS learning (VII): interface and type compatibility of TS
- What causes the wait event of TCP socket (kgas) in oracle?
- 运筹学基础【一】 之 导论
- Source code | opencv DNN + yolov7 target detection
- Summary of UPR optimization suggestions of unity
- Behind Senma's LP, "Wenzhou Department" is running into the venture capital circle
- The LAF protocol elephant of defi 2.0 may be one of the few profit-making means in your bear market
猜你喜欢

Nested if selection structure and switch selection structure

LVGL 8.2 Span

RGB and SATA function switching module based on Quanzhi rk3568j

Unity3d learning note 9 - loading textures

暗黑王者|ZEGO 低照度图像增强技术解析

Simple understanding of RPC

Math. Random, switch selection structure

The LAF protocol elephant of defi 2.0 may be one of the few profit-making means in your bear market

Unity 之 UPR优化建议汇总

Properties of trees
随机推荐
Swagger simple quick start tutorial
The LAF protocol elephant of defi 2.0 may be one of the few profit-making means in your bear market
Cannot make qopenglcontext current in a different thread: the solution to pyqt multithread crash
MySQL -- index and transaction isolation level
看问题的角度
Construction of Seata multilingual system
实战|记一次攻防演练打点
[internship] processing time
@ResponseBody注解的总结
一般在进行数仓迁移过程中,是如何进行数据测试的?
Thinking of reading
LVGL 8.2 Textarea
RGB and SATA function switching module based on Quanzhi rk3568j
Summary of UPR optimization suggestions of unity
TS learning (VII): interface and type compatibility of TS
Chart is code: build a new generation of graphics library in a coded way -- feekin
数据湖(十六):Structured Streaming实时写入Iceberg
如何取得数据库创建时间?
Typical data Lake application cases
ADS1256 debugging notes based on stm32hal Library