Skip to content Skip to sidebar Skip to footer

Lxml Xpath Position() Does Not Work

I tried to scrape a page via XPath but I could not get it work as expected. The page is like, ....

Solution 1:

Thats because you have position()=>1, should be position()>=1

content = root.xpath('string(//div[@id="article"]/p[position()>=1 and position()<=last()]/.)')

will set content to stuff1.

Post a Comment for "Lxml Xpath Position() Does Not Work"