Returning only the number of Google search results through Python

I want to return as soon as possible only the number of Google search results for a particular keyword, avoiding (with minimal) the use of third-party libraries. I already reviewed xgoogle.

+3
source share
2 answers

Take a look at the example of Alex Martelli .

If you are looking for something vague, like โ€œcars,โ€ it datawill look something like this: Note that it is not very long; you get only the best hits and a link to "moreResultsUrl". Therefore, for this request should be fast enough and look in data['cursor']['estimatedResultCount']for an estimated number of hits.

{'cursor': {'currentPageIndex': 0,
            'estimatedResultCount': '168000000',
            'moreResultsUrl': 'http://www.google.com/search?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=cars',
            'pages': [{'label': 1, 'start': '0'},
                      {'label': 2, 'start': '4'},
                      {'label': 3, 'start': '8'},
                      {'label': 4, 'start': '12'},
                      {'label': 5, 'start': '16'},
                      {'label': 6, 'start': '20'},
                      {'label': 7, 'start': '24'},
                      {'label': 8, 'start': '28'}]},
 'results': [ <<list of 4 dicts>> ]}
+2

urllib HTMLParser, <div id="resultStats">....</div>. :

HTMLParser python div?

-1

Source: https://habr.com/ru/post/1756546/


All Articles