[Asm] ´¿Îı¾²é¿´ ¸´ÖÆ´úÂë import re
import requests
from lxml import etree
url = "https://www.qidian.com/all"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
}
sep1=requests.get(url=url,headers=headers).text
tree = etree.HTML(sep1)
detail_url ="https:"+tree.xpath('//div[@class="all-book-list"]//a[1]/@href')[0]
sep2 = requests.get(url=url,headers=headers).text
tree2 = etree.HTML(sep2)
name = tree2.xpath('//*[@id="j-catalogWrap"]/div[2]/div[1]/ul/li')
print(name) |