-1

For example:

http://dir.iran.ir/home?p_p_id=webdirectorydisplay_WAR_webdirectoryportlet&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&_webdirectorydisplay_WAR_webdirectoryportlet_itemEntryId=14439&_webdirectorydisplay_WAR_webdirectoryportlet_cmd=redirectToLink

The final redirected link is :

http://www.dps.ir/
Wai Ha Lee
  • 7,664
  • 52
  • 54
  • 80
ali.mn
  • 1
  • 2

1 Answers1

-1

See this answer: Python Requests library redirect new url

The main idea is following: After you made a urllib request with urllib.request.urlopen(url) it will return a HTTPResponse element. On this element you can call .geturl() to get the final redirected url as string:

>>> import urllib.request
>>> url = "https://python.org"
>>> http_response = urllib.request.urlopen(url)
>>> url_redirected = http_response.geturl()
>>> print(url_redirected)
https://www.python.org/
B Bau
  • 349
  • 3
  • 8