googlesearch icon indicating copy to clipboard operation
googlesearch copied to clipboard

def search never returns if too few results

Open hoppingmonkey opened this issue 1 year ago • 3 comments

Cool library btw.

Small issue when few results returned by google:

In the function def search() if there are too few results, the function never returns.

For example, passing num_results=10 but Google returns less than 10 results, the function will run forever in the loop "while start < num_results:"

A simple way to fix it is using a counter that loops on each sleep of the function.

#init count at the top of the function count = 0

#check the count inside the "while start < num_results:" loop if count < num_results: print("Too few results") break

#loop the count above the "sleep(sleep_interval)" code count += 1.

hoppingmonkey avatar Aug 30 '23 08:08 hoppingmonkey