当前位置:网站首页 > 更多 > 编程开发 > 正文

[Python] 汤圆创作小说检索信息采集

作者:CC下载站 日期:2020-10-04 00:00:00 浏览:52 分类:编程开发

前段时间,因为一些原因,所以需要对这个汤圆创作的小说进行检索,于是写了几行python代码解析了一下搜索出来的结果的信息。

#-*-coding:utf-8-*-
"""
-------------------------------------------------
@Author:Lan
@Blog:www.lanol.cn
@Date:2020/9/30
@Description:I'minchargeofmyCode
-------------------------------------------------
"""
importrequests
importparsel

foriinrange(1,10094):
url=f'https://www.itangyuan.com/search/book/%E4%B8%80%20%E7%94%9F.html?page={i}'
res=requests.get(url).text
xpathFile=parsel.Selector(res)
author=xpathFile.xpath("//p[@class='author']/a/text()").extract()
name=xpathFile.xpath("//p[@class='bname']/a/text()").extract()
info=xpathFile.xpath("//p[@class='rw_info']/text()").extract()
forindex,valueinenumerate(name):
if'一'invalue.replace('','')and'生'invalue.replace('',''):
ifint(info[index].split('阅读')[0].replace('',''))<1000:
print(value,author[index],info[index].split('/')[-1])
print(f'已检测至第{i}页')

大概就是搜索出所有小说名包含一和生字且阅读量小于1000的。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯