为了水篇博客,我也是尽力了。
如果报错,就新建一个文件夹abc
代码语言:javascript复制import requests, parsel
for i in range(1, 37):
res = parsel.Selector(requests.get(f'https://pan.lanol.cn/page_{i}.html').text)
titles = res.xpath("//h2[@class='entry-title']/a/text()").extract()
for index, value in enumerate(res.xpath("//h2[@class='entry-title']/a/@href").extract()):
with open("./abc/" titles[index] '.html', 'a ', encoding='utf8')as f:
f.write(parsel.Selector(requests.get(value).text).xpath("//div[@class='single-content']").extract_first())