add redirect support
This commit is contained in:
parent
67b7dc81e9
commit
fe61491292
@ -28,6 +28,11 @@ def get_page(url):
|
|||||||
|
|
||||||
conn.request("GET", up.path, None, headers)
|
conn.request("GET", up.path, None, headers)
|
||||||
response = conn.getresponse()
|
response = conn.getresponse()
|
||||||
|
if (response.status == http.client.MOVED_PERMANENTLY) \
|
||||||
|
or (response.status == http.client.FOUND):
|
||||||
|
new_url = response.getheader('Location')
|
||||||
|
print('Redirect to ' + new_url)
|
||||||
|
return get_page(new_url)
|
||||||
|
|
||||||
# get page charset from response header
|
# get page charset from response header
|
||||||
contenttype = response.getheader('Content-Type')
|
contenttype = response.getheader('Content-Type')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user