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