Google-Search-API icon indicating copy to clipboard operation
Google-Search-API copied to clipboard

search_results taking empty list values

Open Scotchex opened this issue 4 years ago • 3 comments

For 90% of the time the search_results list is taking empty values in hence, i am facing out of range errors. Here is an example of the code that only works 10% of the time:

`from googleapi import google def googleSearch(searchterm): num_page = 1 search_results = google.search(searchterm, num_page) return search_results[0].description

x = input('search?') print(googleSearch(x))`

Scotchex avatar Feb 02 '21 15:02 Scotchex

I got the same error. The reason is that Google made changes to their design and the HTML structure and thus the parsing failed. Since they use A/B testing for sure (X% of users get one design and other Y% of users get another design). Sometimes the parsing fails and sometimes not (the old design seem to be returned in 10% of the cases). I got at least 4 different HTML structures when I tested it. https://github.com/abenassi/Google-Search-API/pull/93 includes a fix for that...

kulla avatar Feb 10 '21 22:02 kulla

i got the same, i'm trying to use it but the result is just an empty list.

from googleapi import google
num_page = 1
search_results = google.search("my query", num_page)
print(search_results)

did i miss some thing ? please help me, thank you so much.

batman616 avatar Sep 17 '21 09:09 batman616

Still doesn't work, seems deprecated no longer supported.

from googleapi import google
num_page = 1
search_results = google.search("google", num_page)

print(search_results)

for result in search_results:
    print(result.link)

Result:

[]
[Finished in 1.2s]

danielcshn avatar Feb 16 '23 21:02 danielcshn