Here is the Requests way:
import requests
r = requests.get('http://github.com', allow_redirects=False)
print(r.status_code, r.headers['Location'])
More Related Contents:
- Python Requests library redirect new url
- urllib2.HTTPError: HTTP Error 403: Forbidden
- How to add both file and JSON body in a FastAPI POST request?
- How to avoid HTTP error 429 (Too Many Requests) python
- Django return redirect() with parameters
- Python: HTTP Post a large file with streaming
- Python urllib2 with keep alive
- How do I check if stdin has some data?
- Python ‘requests’ library – define specific DNS?
- Cannot redirect output when I run Python script on Windows using just script’s name
- Why am I getting this error in python ? (httplib)
- Python + Django page redirect
- How to implement retry mechanism into python requests library?
- How to get http headers in flask?
- How to scrape a website that requires login first with Python
- Save a large file using the Python requests library [duplicate]
- Python requests speed up using keep-alive
- Python: How do I get key/value pairs from the BaseHTTPRequestHandler HTTP POST handler?
- How to redirect with messages to display them in Django Templates?
- Why am I getting httplib.BadStatusLine in python?
- Python – make a POST request using Python 3 urllib
- How to get the URL of a redirect with Python
- Http Redirection code 3XX in python requests
- Does Django have a way to open a HTTP long poll connection?
- how to follow meta refreshes in Python
- How to redirect from a view to another view In Django
- Is there a library for retrieving a file from a remote zip? [closed]
- Python seek on remote file using HTTP
- FastAPI’s RedirectResponse doesn’t work as expected in Swagger UI
- Python requests.exception.ConnectionError: connection aborted “BadStatusLine”