37,718
社区成员
发帖
与我相关
我的任务
分享
import requests
from lxml import etree
HEADERS={
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36'
}
URL='https://blog.csdn.net/weixin_45949073/article/list/'
#response = requests.get(url=URL,headers=HEADERS).text
response = requests.get(url=URL,headers=HEADERS).content.decode('utf-8')
html = etree.HTML(response)
detail_ur = html.xpath("//div[@class='pagination-box']//div[@class='ui-paging-container']//ul//li/@data-page")#明明是可以提取出来的,如下图,但是输出确实空列表
print(detail_ur)