Reputation: 8478
If we type a search term in Google search box, it returns something like:
About x results (y seconds)
How can I extract this line from the search results using Python 3? Thanks for your help.
Upvotes: 0
Views: 317
Reputation: 369064
>>> import urllib.request
>>> import lxml.html
>>> html = .. urllib.request.urlopen .. http://www.google.com/search?q=python ..
.read()
>>> root = lxml.html.fromstring(html)
>>> div, = root.cssselect('#resultStats')
>>> div.text_content().strip()
'About 46,600,000 results (0.17 seconds)'
Upvotes: 3