技术有限,代码乱七八糟的见谅
不知道怎么保存到文本,或者 最好保存数据库里面,
烦请各位看官帮忙优化一下谢谢
[Asm] 纯文本查看 复制代码import requests
from lxml import etree
head = {'Cookie': '',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36'}
for i in range(100):
for h in range(100):
url = f'https://www.52pojie.cn/forum-{h}-{i}.html'
res = requests.get(url)
e = etree.HTML(res.text)
name = e.xpath('//*[@id="threadlisttableid"]/tbody/tr/th/a/text()')
names = e.xpath('//*[@id="threadlisttableid"]/tbody/tr/th/a/@href')
for no,no1 in zip(name,names):
print(f'标题:{no} 链接:https://www.52pojie.cn/{no1}')