I'm trying to make a basic program for google search. The first step is accessing the google web page for the results, for which I use:
http://google.com/search?q=something+somethang
With 'something something' being the query. What I get from the logging info is that I'm being redirected to:
2015-06-10 13:08:36,815 - INFO - Starting new HTTP connection (1): google.com
2015-06-10 13:08:37,487 - DEBUG - "GET /search?q=something+somethang HTTP/1.1" 302 359
2015-06-10 13:08:37,601 - INFO - Starting new HTTP connection (1): ipv4.google.com
2015-06-10 13:08:37,750 - DEBUG - "GET /sorry/IndexRedirect?continue=http://google.com/search%3Fq%3Dsomething%2Bsomethang&q=CGMSBJgH4AYYzN_hqwUiGQDxp4NLfKUWBsQJL2TkqfCe8pFtltJvTB0 HTTP/1.1" 503 2659
2015-06-10 13:08:37,831 - DEBUG - 503
The last line I printed, it's the status_code for the request.
I checked the link:
google.com/sorry/IndexRedirect?continue=http://google.com/search%3Fq%3Dsomething%2Bsomethang&q=CGMSBJgH4AYYzN_hqwUiGQDxp4NLfKUWBsQJL2TkqfCe8pFtltJvTB0
and it's to check for bots and stuff. Is there no way to make the program work?
Best,
It seems whatever method you are using to fetch the webpage doesnt have follow redirects set to True.
Following should work -
You may also need to send the User-Agent string header.