current position:Home>Xpath parsing out list is empty, no tbody annotations

Xpath parsing out list is empty, no tbody annotations

2022-08-06 09:23:34CSDN Q&A

If you don't understand, ask, why is this parsed as an empty list

```pythonimport requestsfrom lxml import etreeimport pprinturl = "https://smx.58.com/shanxiansmx/zufang/"head = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36 SE 2.X MetaSr 1.0"}reponse = requests.get(url= url,headers=head)page = reponse.texttree = etree.HTML(page)print(tree)print("~"*30)name = tree.xpath("//div[@class='des']/h2/a[class='strongbox']/text()")print(name)print("~"*30)huxing = tree.xpath("//div[@class='des']/h2/p[class='room']/text()")pprint.pprint(huxing)print("~"*30)zujin = tree.xpath("//div[@class='money']/b/text()")pprint.pprint(zujin)print("~"*30)dizhi = tree.xpath("//div[@class='des']/p[@class='infor']/a/text()")pprint.pprint(dizhi)print("~"*30)

```

copyright notice
author[CSDN Q&A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/218/202207301816025365.html

Random recommended