from lxml import etree import requests r=requests.get('https://b.faloo.com/163306.html') h=etree.HTML(r.text) url_list=h.xpath('//div[@class="DivTd"]/a/@href') url_list=['https:'+i for i in url_list] for i in url_list: r1 = requests.get(i) h1=etree.HTML(r1.text) result=h1.xpath('//div[@class="noveContent"]/p/text()') for y in result: with open('与校花同居的大盗.txt','a',encoding='utf-8') as f: f.write(y) f.write('\n')
4.20爬虫作业
最新推荐文章于 2024-08-18 23:40:08 发布