I have a shortened url:
https://dl.flipkart.com/s/XermJqNNNN
which expands to:
https://www.flipkart.com/beatxp-prime-deep-tissue-electric-massage-gun-machine-full-body-pain-relief-percussion-massager/p/itmb8e3cc771527c?pid=MASGHMJHYUJCN3WQ&cmpid=product.share.pp&_refId=PP.f843e983-04ea-4b65-b58d-413f2d9ee16f.MASGHMJHYUJCN3WQ&_appId=CL
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).