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

how to set time limit between every request?

Open tohfaakib opened this issue 6 years ago • 4 comments

I don't want google to detect this system as bot. so what can i do. I want to perform 100 of pages to be redirected without getting ban. Time doesn't matter.

tohfaakib avatar Jul 30 '18 11:07 tohfaakib

Simply wait a random time between queries using time.sleep(). Note that every 100 queries, you should wait a little bit more. This way has worked for me without getting 503 errors.

import time
from random import randint

count = 0

for query in queries:
    search_results = google.search(query,ncr=True)
    # do whatever you wanna do with the results, then

    if count % 100 != 0:
        nap = randint(45,60)
    else:
        nap = randint(180,240)

    count +=1
    time.sleep(nap)

JuaniFilardo avatar Aug 17 '18 12:08 JuaniFilardo

I want the result for same query. there will be one query and the page will be 100 in number.

my code

from google import google

num_page = 100

query= input("Enter Search Query: ")

query = que+query

search_results = google.search(query, num_page)

for result in search_results:
    # my code to play with results

i want some result of 100 page for a specific query without getting marked as bot or robot. time doesn't matter. how to do it?

tohfaakib avatar Aug 17 '18 20:08 tohfaakib

Oh, I see. The query is "just one", but you're actually making it 100 times, for pages 1 to 100. This is a workaround you can use:

  • Edit the function search from google/modules/standard_search.py, and add a time.sleep() somewhere in the for i in range(pages): loop.

JuaniFilardo avatar Aug 17 '18 20:08 JuaniFilardo

I already did but actually not working.

tohfaakib avatar Aug 17 '18 20:08 tohfaakib