Lorenzo Beronilla
Lorenzo Beronilla

Reputation: 55

python google query returning only a single result

This code, according to "geeksforgeeks" should return 10 results however for me it is only returning one. Any thoughts?

try: 
    from googlesearch import search 
except ImportError: 
    print("No module named 'google' found") 

query = "dogs"

for j in search(query, tld="co.in", num=10, stop=1, pause=2): 
    print(j) 

Upvotes: 1

Views: 459

Answers (1)

mkrieger1
mkrieger1

Reputation: 23255

I'm assuming you are using this library:

https://github.com/MarioVilas/googlesearch

According to its documentation, you are misunderstanding what the function arguments mean.

  • num (int) – Number of results per page

  • stop (int) – Last result to retrieve. Use None to keep searching forever.

By using stop=1 you only get one result. Change it to something higher.

Upvotes: 2

Related Questions