Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85747

Re: URL - Python ?

Date 2015-02-17 17:45 +0100
From Emil Oppeln-Bronikowski <emil@fuse.pl>
Subject Re: URL - Python ?
References <0ee84d3b-0223-4c0b-a089-1722504ed7bc@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.18790.1424193116.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

> I would want to know if it's possible to trace the url to the new location

If the webmaster did a proper thing you'll get server 3xx HTTP header 
that will point you to new URL.

http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection

If you're using a good library to do your HTTP (like requests) the 
URL-following is build in and free

>>>r  =  requests.get('http://github.com')
>>>r.url
'https://github.com/'
>>>r.status_code
200
>>>r.history
[<Response [301]>]

If you want to track changes just check if response.history has some items in it.

-- 

Emil Oppeln-Bronikowski *|* http://fuse.pl

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

URL - Python ? Josef Achkar <josef.achkar@gmail.com> - 2015-02-17 08:38 -0800
  Re: URL - Python ? Emil Oppeln-Bronikowski <emil@fuse.pl> - 2015-02-17 17:45 +0100

csiph-web