This problem is mainly not headers, add some content can be
Example:
# -*-coding:utf-8-*- Import Urllib2site " http://www.nseindia.com/live_market/dynaContent/live_watch/get_quote/getHistoricalData.jsp?symbol= Jpassociat&fromdate=1-jan-2012&todate=1-aug-2012&dateperiod=unselected&hidddwnld=true "= {'user-agent':'mozilla/5.0' = Urllib2. Request (site,headers== Urllib2.urlopen (req)
An error occurred in the header:
Join headers:
1 ImportUrllib22 3Sizes"http://www.nseindia.com/live_market/dynaContent/live_watch/get_quote/getHistoricalData.jsp?symbol= Jpassociat&fromdate=1-jan-2012&todate=1-aug-2012&dateperiod=unselected&hidddwnld=true"4HDR = {'user-agent':'mozilla/5.0 (X11; Linux x86_64) applewebkit/537.11 (khtml, like Gecko) chrome/23.0.1271.64 safari/537.11',5 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',6 'Accept-charset':'iso-8859-1,utf-8;q=0.7,*;q=0.3',7 'accept-encoding':'None',8 'Accept-language':'en-us,en;q=0.8',9 'Connection':'keep-alive'}Ten Onereq = Urllib2. Request (Site, headers=HDR) A - Try: -page =Urllib2.urlopen (req) the exceptUrllib2. Httperror, E: - PrintE.fp.read () - -Content =Page.read () + PrintContent
See if it's successful?!
Urllib2. Httperror:http Error 403:forbidden