I want to get some data from website, for example : image URL, Page Title etc.
But response is not good.
Code :
import urllib2
from 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
for i 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, I am getting this HTML page. Includes the URL i am calling through python script (urllib2 module)
Even Response Module of python react as same!
I don't know how to get proper response!! Please Help !