I am trying to parse HTML using
a = lxml.html.fromstring('<html><body><span class="cut cross">Text of double class</span><span class="cross">Text of single class</span></body></html>') s1 = a.xpath('.//span[@class="cross"]') s2 = a.xpath('.//span[@class="cut cross"]') s3 = a.xpath('.//span[@class="cut"]')
Output:
s1 => [<Element span at 0x7f0a6807a530>] s2 => [<Element span at 0x7f0a6807a590>] s3 => []
But the first span tag has a class of 'cut', but s3 is empty. So far in s2, when I give both classes, it returns a tag.
source share