weixin_37586358
weixin_37586358
2021-01-21 17:33

python xpath返回空值

  • python
代码如下:

import requests
import parsel

base_url = 'https://jasonzou.tuchong.com/posts'
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Safari/605.1.15'}

response = requests.get(url=base_url,headers=headers)
html_data = response.text
#print(html_data)


parse=parsel.Selector(html_data)
data_list = parse.xpath('//div[@class="page-content"]//ul/div/@data-url').getall()
print(data_list)

返回值[],找不到原因

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

0条回答