xpath
这样的xpath该怎么写 li_list = response.xpath('//*[@id="body"]/div/div/div/div/div/div')for li in li_list:
comtent_01 = li.xpath('./p/text()')
comtent_02 = li.xpath('./p/text()')
comtent_03 = li.xpath('./p/text()')
这样写感觉好繁琐,怎样可以简化一下呢 import requests
from lxml import etree
resp = requests.get('https://www.xiaohuaduanzi.cn/duanzi/329394.html')
html = etree.HTML(resp.text)
p_lst = html.xpath('//*[@id="body"]/div/div/div/div/div/div/p')
for i in p_lst:
print(i.text) isdkz 发表于 2023-2-10 21:36
好的,感谢感谢 哈岁NB 发表于 2023-2-10 21:58
好的,感谢感谢
如果问题解决了就给个最佳答案呗{:5_92:}
页:
[1]