So I would like to get all the a tags inside all the td class=”banana” but only if this td contains the text “Today”
import lxml.html
html = lxml.html.parse("http://www.sitetoscrape.com/")
a = html.xpath('//td[@class="banana"]//text[@text="Today"]//a')
print a
This returns an empty list, if I take out “//text[@text=”Today”]” it works, but I get back all the links inside all the td class=’banana’
It’s hard to give an accurate answer without an example, but something like that should do it.