I have a shortened url: https://dl.flipkart.com/s/XermJqNNNN
I want to retrieve this redirected URL.
import requests
def get_original_url(short_url):
try:
response = requests.get(short_url, allow_redirects=False)
if 'Location' in response.headers:
return response.headers['Location']
else:
return "Original URL not found in the response."
except requests.exceptions.RequestException as e:
return f"An error occurred: {e}"
I tried the above method which gives me the correct redirect URL in my local system(Windows). But returns the same shortened URL when deployed to the app service on Render(Linux).
requests.get(short_url, allow_redirects=False). So you need to look at the code that responds to thedl.flipkar.comURL, not the code you posted here.