0

I'm attempting to execute a simple Google search in Python using the requests library. They query, header and request are shown below:

query = 'https://www.google.com/search?q=search+term&ie=utf-8' 

header = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15'}

resp = requests.get(query, headers=header)

The code runs successfully when executed from my laptop (MacBook Pro running macOS Monterey and Python 3.9). However, I'm using a hosting provider and need to run this same code from a server. When I attempt to execute the search I get a 429 error from Google. I understand that this would normally indicate too many requests are being submitted, but it happens with a single request. It feels like there's something environmental going on, but I'm unsure as to how to address it.

Update: I tried using a couple of different proxies and got the same result (429 return code).

Scott
  • 11
  • 4
  • 1
    Does this answer your question? [Error 429 with simple query on google with requests python](https://stackoverflow.com/questions/56758333/error-429-with-simple-query-on-google-with-requests-python) – zvi Jun 13 '22 at 20:06
  • Unfortunately, it does not. I can get the query to work if I omit the '/search' parameter from the request. However, then I don't get any results. – Scott Jun 13 '22 at 20:30

1 Answers1

0

You've sended to much Requests. Look here, your Question is an Duplicate:

https://stackoverflow.com/questions/56758333/error-429-with-simple-query-on-google-with-requests-python#:~:text=The%20HTTP%20429%20Too%20Many,before%20making%20a%20new%20request.

Hope this Helps.

1 Guy there said, the Problem are Cookies. You have to Save them and add them by the next Request.

Fido_de07
  • 73
  • 1
  • 6
  • As I mentioned in my post, the 429 error code comes back the first time I execute a single request, so I don't believe it's at all related to volume. I also tried the cookie solution earlier and didn't have any success. – Scott Jun 13 '22 at 20:26
  • Sorry, i didnt saw. This is only by your Server, maybe the Network/IP is blocked by Google? You can use a Proxie in Requests Module. – Fido_de07 Jun 13 '22 at 20:31
  • I think a proxy might be the answer. I've also opened a ticket with the hosting service to see if they've encountered this with other accounts. Thanks for the quick responses. – Scott Jun 13 '22 at 20:50
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 14 '22 at 05:01