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

Lan
Lan
2020-10-04 / 0 评论 / 715 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2020年10月04日,已超过1306天没有更新,若内容或图片失效,请留言反馈。

image.png

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

# -*- coding: utf-8 -*-
"""
-------------------------------------------------
@ Author :Lan
@ Blog :www.lanol.cn
@ Date : 2020/9/30
@ Description:I'm in charge of my Code
-------------------------------------------------
"""
import requests
import parsel

for i in range(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()
    for index, value in enumerate(name):
        if '一' in value.replace(' ', '') and '生' in value.replace(' ', ''):
            if int(info[index].split('阅读')[0].replace(' ', '')) < 1000:
                print(value, author[index], info[index].split('/')[-1])
    print(f'已检测至第{i}页')

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

0

评论 (0)

取消