我无法从网站www.nse.com下载文件...当我尝试运行代码时,它会显示以下消息
错误: - 拒绝访问
You don't have permission to access "http://www.nseindia.com/content/historical/EQUITIES/2016/JUN/cm13JUN2016bhav.csv.zip" on this server.<P>
Reference #18.4ef0ef75.1465880369.ab8f79e
</BODY>
</HTML>
未下载
我的代码就是这样:
CODE
import urllib2
urlOfFileName="http://www.nseindia.com/content/historical/EQUITIES/2016/JUN/cm13JUN2016bhav.csv.zip"
localZipFilePath="C:\Users\sai\Desktop\cm13JUN2016bhav.csv.zip"
hdr ={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36'}
webRequest=urllib2.Request(urlOfFileName,headers=hdr)
try:
page=urllib2.urlopen(webRequest)
content=page.read()
output=open(localZipFilePath,"wb")
output.write(bytearray(content))
output.close()
except urllib2.HTTPError,e:
print e.fp.read()
print "Not Downloaded"
我也使用了User_Agent Header ..我无法理解这个问题。请帮我解决这个问题。