URL - Python ?
Emil Oppeln-Bronikowski
emil at fuse.pl
Tue Feb 17 11:45:32 EST 2015
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150217/352aa180/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fusetiny.png
Type: image/png
Size: 2504 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20150217/352aa180/attachment.png>
More information about the Python-list
mailing list