python urllib2, No proper response -


i want data website, example : image url, page title etc.

but response not good.

code :

import urllib2 bs4 import beautifulsoup  url_list = [     "https://www.nfm.com/detailspage.aspx?productid=43382514" ]  # image urlhttps://www.nfm.com/getphoto.ashx?productid=43382514&size=l   def get_data(url):     user_agent = '"mozilla/5.0 (x11; u; linux i686) gecko/20071127 firefox/2.0.0.11"'     headers = {'user-agent': user_agent}     page = urllib2.request(url, none, headers)     page2 = urllib2.urlopen(page)     soup = beautifulsoup(page2, 'html.parser')     print soup.prettify('latin-1')     # img_url = https://www.nfm.com/getphoto.ashx?productid=43382514&size=l  in url_list:     get_data(i) 

result is:

<html>  <body>   <script type="text/javascript">    document.cookie="ns_cls="+"w:"+screen.width+",h:"+screen.height+",ua:"+escape(navigator.useragent) window.location.href = "**https://www.nfm.com/detailspage.aspx?productid=43382514**"   </script>  </body> </html> 

so, getting html page. includes url calling through python script (urllib2 module)

even response module of python react same!

i don't know how proper response!! please !


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -