Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Google Search return HTTP Error 403?

Tags:

People also ask

What does the HTTP error code 403 mean?

The HTTP 403 Forbidden response status code indicates that the server understands the request but refuses to authorize it.


Consider the following Python code:

 30    url = "http://www.google.com/search?hl=en&safe=off&q=Monkey"
 31    url_object = urllib.request.urlopen(url);
 32    print(url_object.read());

When this is run, an Exception is thrown:

File "/usr/local/lib/python3.0/urllib/request.py", line 485, in http_error_default
   raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

However, when this is put into a browser, the search returns as expected. What's going on here? How can I overcome this so I can search Google programmatically?

Any thoughts?