为了水篇博客,我也是尽力了。
如果报错,就新建一个文件夹abc

import requests, parsel
for i in range(1, 37):
res = parsel.Selector(requests.get(f'https://gitlab.com/Vastsa/lanpicbed/-/raw/master/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())
评论 (0)