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

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -