我是新手使用xpath并尝试从网页http://www.symantec.com/security_response/writeup.jsp?docid=2000-122015-2208-99
中提取数据 xpath //dl
,//dt
和//dd
为我返回空列表,而//h1
,//h2
,//div
,{{1} }},//a
以及我能想到的其他所有尝试按预期工作的内容。 //p
,//dl
和//dt
xpath适用于其他具有相关标签的网页。
为什么会对此网页发生这种情况,如何访问dl,dt和dd节点?
我的(python)代码的相关部分是
//dd
除了from lxml import html
import requests
url = 'http://www.symantec.com/security_response/writeup.jsp?docid=2000-122015-2208-99?'
htmlp = requests.get(url)
tree = html.fromstring(htmlp.text)
dlList = tree.xpath('//dl')
#How I'm checking to see if dlList is empty
print len(dlList)
print dlList[0]
,//dl
或//dt
之外,我似乎还可以使用。 //dd
等也不起作用。