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

Google standard search takes over 3 seconds to return answer

Open SearchPirat opened this issue 6 years ago • 7 comments

Hey abenassi,

I tried your code and I'm very happy with it. I only have the issue, that each google request takes at minimum 3s. I'm using the function as follows:

import urllib.request as urllib2 from google import google

num_pages =1 Google_result = google.search(query, num_pages, lang = 'de', area = 'de')

I would be very happy if you could help me.

Best regards, SearchPirat

SearchPirat avatar Jun 25 '18 16:06 SearchPirat

Hi @SearchPirat!

As far as I'm concerned, that's the time that each requests takes; I'm not pretty sure what could be done to reduce it (maybe some refactoring of the API itself?). I mean, scraping the whole html returned by Google and processing it takes time, so it's not that you're doing something wrong.

Have a nice day!

PS: the area param is no longer working, check issue 52 for further information.

JuaniFilardo avatar Jun 29 '18 23:06 JuaniFilardo

Hi @JuaniFilardo Thank you for your fast reply. Good to know, that there is nothing that I'm doing wrong. I just thought it may be possible to limit the search results or the time for searching. This would also limit the time it would take to scrape the html results.

Have a nice one SearchPirat

SearchPirat avatar Jul 01 '18 10:07 SearchPirat

By default, the search method will return the ten results from the first page from Google. Would you want to get, for example, just the first 5 results?

JuaniFilardo avatar Jul 01 '18 17:07 JuaniFilardo

If this would speed the search up by a factor of 2 it would be a possible solution.

SearchPirat avatar Jul 02 '18 16:07 SearchPirat

@JuaniFilardo Is this possible?

SearchPirat avatar Jul 11 '18 17:07 SearchPirat

Um, I really don't know if the improvement would be that significant. Maybe you could try hardcoding the library in order to fetch fewer results, and then measuring the mean time it takes.

JuaniFilardo avatar Jul 11 '18 23:07 JuaniFilardo

ran a quick test, lxml reduces the overall time to less than 0.8 sec(location: DE, VPS: Vultr)

lxwang42 avatar Jan 23 '19 20:01 lxwang42