Scrambling text with xpath / lxml
I am trying to clear the text "2005-2013" from the text that says "drink between: 2005 - 2013" from http://www.cellartracker.com/wine.asp?iWine=91411 using xpath / lxml and I can do this only for some of the other pages on this site, not for this. Not sure what I am doing wrong / if the xpath I copied from the element is wrong
tell me:
print(content_divs[0].text_content().strip())
IndexError: list index out of range
Here's my code:
import requests, lxml.html
page = requests.get('http://www.cellartracker.com/wine.asp?iWine=91411')
html = lxml.html.fromstring(page.content)
content_divs = html.xpath('//*[@id="wine_copy_inner"]/p/a[4]')
print(content_divs[0].text_content().strip())
thank you for your help!!!
+3
source to share
2 answers