hi, here are my two codes:
First :
Why does it return an empty list since it doesn't for title's xpath ?
Any solution ? Thanks !
As you can see, i tried two differents ways to do it, but both does the same
First :
page = requests.get('http://www.google.fr/') tree = html.fromstring(page.content) test1 = tree.xpath('/html/head/title/text()') test2 = tree.xpath('//*[@id="fbar"]/div/div/text()') # xpath from 'France' which is at bottom-left corner of the screen print test1 print test2Output :
Output:['Google']
[/python]
Second :parser = etree.HTMLParser() html = etree.parse('http://www.google.fr/',parser) result = html.xpath('/html/head/title/text()') result2 = html.xpath('//*[@id="fbar"]/div/div/text()') # xpath from 'France' which is at bottom-left corner of the screen print result print result2Output :
Output:['Google']
[]
Using google chrome, i right click on 'France' and take its xpath. Why does it return an empty list since it doesn't for title's xpath ?
Any solution ? Thanks !
As you can see, i tried two differents ways to do it, but both does the same