python - urllib2 redirect empty page (though code is 200 and geturl() points to new page) -
i trying access web page using urllib2 , automatic redirect in urllib2 not seem retrieve entire page. here code:
request = urllib2.request(link) request.add_header('user-agent','...') opener = urllib2.build_opener() page = opener.open(request) print(page.code) print(page.geturl()) print(page.read())
a) when link = 'https://www.google.com'. prints
200 https://www.google.com <!doctype...> etc. etc. </script>
b) when link = 'https://www.xyz.com/a_link_which_is_redirected.html'. prints
200 https://the_new_link <blank>
however, if access 'link' in b) via internet browser, correctly displays page form.
view source of google page - end script tag. leave off of closing tags because browsers can still interpret correctly , saves bandwidth.
here test redirect pages. of not work you?
Comments
Post a Comment