Search code examples
pythongoogle-search

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) 

Solution

  • 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.