-1

I have a URL that looks like http://www.example.com/link?url=http://www.google.com. And the URL redirects to http://www.google.com when opened in the browser. But when I check the status code of the URL, it shows 200 instead of 3xx. Even if I check with print(url.history) it shows []. Please explain!

Edit: I checked the response of the request it was like :

var url = 'http://www.google.com';
window.location=url;
</script>
<!-- Form pop up box -->
    <div id="popUpPageConatiner" style="display:none;" ></div>
<!-- close form pop up box -->
  • This seems to be a DUPE question https://stackoverflow.com/questions/20475552/python-requests-library-redirect-new-url – Wonka Dec 16 '19 at 16:06
  • 3
    Does this answer your question? [Python Requests library redirect new url](https://stackoverflow.com/questions/20475552/python-requests-library-redirect-new-url) – Wonka Dec 16 '19 at 16:06
  • 1
    https://2.python-requests.org/en/master/user/quickstart/#redirection-and-history – chepner Dec 16 '19 at 16:07
  • Sorry, but it still doesn't resolve my issue. –  Dec 16 '19 at 16:16

1 Answers1

1

requests.get by default running with {'allow_redirects': True}, which means you will have response.status_code output 200, not 302 or 301.

Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58
Oleg Butuzov
  • 4,795
  • 2
  • 24
  • 33