利用feapder解析知乎文章标题和url

it不难
2022-07-19 / 0 评论 / 10 阅读 / 正在检测是否收录...

前言

python脚本内容

from feapder.network.selector import Selector

with open('a.html', 'r') as f:
    text = f.read()

selector = Selector(text)
r_list = selector.xpath('//div[@class="List-item"]')
for r in r_list:
    title = r.xpath('./div/div/h2/span/a/text()').extract_first()
    url = r.xpath('./div/div/h2/span/a/@href').extract_first()
    aurl = "https:{}".format(url)
    print("{},{}".format(title,aurl))
0

评论 (0)

取消