Reputation: 11
import requests
url = "https://zephr.app/pu?u=db3f63382398497c8d6a52b06cd7a880"
headers = {"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"}
response = requests.get(url,headers=headers)
for res in response.history:
print(res.url)
I find a solution online but this didn't solve my problem.
And the response code I got is 503. But if I open this link, this will redirect to another link. Appreciate it if you can help me out! this is the url https://zephr.app/pu?u=db3f63382398497c8d6a52b06cd7a880
Upvotes: 1
Views: 49
Reputation: 641
To get the resultant URL after you've been redirected, you can do r.url
.
r = requests.get('https://zephr.app/pu?u=db3f63382398497c8d6a52b06cd7a880')
print(r.url) # https://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtu.be
Upvotes: 1