Wizzard
Wizzard

Reputation: 12702

Python, url from request

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?

Upvotes: 0

Views: 121

Answers (1)

Wizzard
Wizzard

Reputation: 12702

This is done with

self.response.geturl()

Upvotes: 1

Related Questions