开发者

Python, url from request

开发者 https://www.devze.com 2023-01-25 22:18 出处:网络
I am 开发者_如何转开发trying to get the url of the page I just fetched - as it can change after redirects...

I am 开发者_如何转开发trying to get the url of the page I just fetched - as it can change after redirects...

        opener = urllib2.build_opener(redirect_handler.MyHTTPRedirectHandler())
        opener.addheaders = [('Accept-encoding', 'gzip')]
        self.response = opener.open(url)
        self.page_contents = self.response.read()

However, due to redirects sometimes the page I request isn't the page I get.... how can I get the final url - I have tried to find a param on the self.response and looking at the docs isn't helping....

Any pointers?


This is done with

self.response.geturl()
0

精彩评论

暂无评论...
验证码 换一张
取 消