Redirection url using urllib in Python 3

后端 未结 1 602
醉梦人生
醉梦人生 2021-01-19 11:01

I would need to know what is my final URL when following redirections using urllib in Python 3.

Let\'s say I\'ve some code like :

opener = urllib.req         


        
相关标签:
1条回答
  • 2021-01-19 11:21

    You can simply use

    u.geturl()
    

    to get the URL you were redirected to (or the original one if no redirect happened).

    0 讨论(0)
提交回复
热议问题