Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'back.': 0.09; 'http': 0.09; 'parameter': 0.09; 'subject:How': 0.10; 'cc:addr:python- list': 0.11; 'handler.': 0.16; 'headers.': 0.16; 'received:166.84': 0.16; 'received:166.84.1': 0.16; 'received:166.84.1.89': 0.16; 'received:24.136': 0.16; 'received:mailbackend.panix.com': 0.16; 'received:panix.com': 0.16; 'roy': 0.16; 'subject:URL': 0.16; 'subject:after': 0.16; 'url.': 0.16; 'url:creative': 0.16; 'url:tag': 0.16; 'used).': 0.16; 'wrote:': 0.18; 'library': 0.18; 'mechanism': 0.19; 'received:166': 0.19; 'code,': 0.22; 'cc:addr:python.org': 0.22; '31,': 0.24; 'body,': 0.24; 'headers': 0.24; 'url:utf8': 0.24; "haven't": 0.24; 'looks': 0.24; '(or': 0.24; '---': 0.24; 'environment': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'received:24': 0.27; 'tried': 0.27; "doesn't": 0.30; 'url:gp': 0.30; 'url:mailman': 0.30; '(which': 0.31; 'code': 0.31; 'requests': 0.31; "skip:' 10": 0.31; 'that.': 0.31; 'url:python': 0.33; "can't": 0.35; 'case,': 0.35; 'but': 0.35; 'google': 0.35; 'described': 0.36; 'url:ie': 0.36; 'url:ref': 0.36; 'done': 0.36; 'url:listinfo': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'url:amazon': 0.38; 'pm,': 0.38; 'anything': 0.39; 'does': 0.39; 'url:mail': 0.40; 'include:': 0.61; 'location:': 0.61; 'tracking': 0.61; 'full': 0.61; "you're": 0.61; 'header:Message-Id:1': 0.63; 'kind': 0.63; 'provide': 0.64; 'to:addr:gmail.com': 0.65; 'smith': 0.68; 'subject:get': 0.81; 'email addr:panix.com': 0.84; 'horrible': 0.84; '2013,': 0.91; 'joel': 0.91; 'thing,': 0.91; 'url:latest': 0.91; 'examine': 0.93; 'imagine': 0.93 Subject: Re: How to get final URL after redirection Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: text/plain; charset=us-ascii From: Roy Smith In-Reply-To: Date: Thu, 31 Oct 2013 14:50:07 -0400 Content-Transfer-Encoding: quoted-printable References: To: Joel Goldstick X-Mailer: Apple Mail (2.1283) Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1383245410 news.xs4all.nl 16007 [2001:888:2000:d::a6]:51129 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58203 On Oct 31, 2013, at 2:43 PM, Joel Goldstick wrote: >> The "normal" way a redirect is done is to return a 301 (or 302) = status code, and include a Location: line in the HTTP response headers. = If that was the case, you would just do a GET on the url with a library = like requests and examine the status code and headers in the response = object you got back. >>=20 >> This URL, however, doesn't do that. What it does do is include: >>=20 >> >>=20 >> in the body, which does kind of the same thing, but in a horrible = way. I suspect they do this provide a hook for the google analytics = tracking code in the window.onload handler. Unless you wanted to = include a full HTML and javascript execution environment in your = application, you're pretty much toast here. >> -- >> https://mail.python.org/mailman/listinfo/python-list >=20 > You might look at the requests module: > http://www.python-requests.org/en/latest/api/ >=20 > It has an 'allow_redirects' parameter that looks like you can set to > get the final url. Haven't tried it I can't imagine this does anything other than the 30x processing = described above (which won't work in the OP's case because that's not = the mechanism used). --- Roy Smith roy@panix.com