我想從這個頁面解析審查,以解析HTML:http://www.amazon.co.uk/product-reviews/B00143ZBHY無法使用lxml的Xpath的解析器
使用以下方法:
代碼
html # a variable which contains exact html as given at the above page.
from lxml import etree
tree = etree.HTML(html)
r = tree.xpath(".//*[@id='productReviews']/tbody/tr/td[1]/div[9]/text()[4]")
print len(r)
print r[0].tag
輸出
0
Traceback (most recent call last):
File "c.py", line 37, in <module>
print r[0].tag
IndexError: list index out of range
p,s ,:在Firefox的xpath檢查器插件上使用相同的xpath時,我可以輕鬆地解決它。但這裏沒有結果,請幫忙!
不知道爲什麼,鉻顯示了XPath TBODY :( – codersofthedark 2012-07-12 19:24:24
它自動生成 – fedosov 2012-07-12 21:44:11