开发者

urllib.urlretrieve is failing

开发者 https://www.devze.com 2023-03-23 12:23 出处:网络
I\'m trying to download data using commands below. import urllib url = \'http://www.nse-india.com/content/historical/EQUITIES/2002/MAR/cm01MAR2002bhav.csv.zip\'

I'm trying to download data using commands below.

import urllib
url = 'http://www.nse-india.com/content/historical/EQUITIES/2002/MAR/cm01MAR2002bhav.csv.zip'
urllib.urlretrieve(url, 'myzip')

Wh开发者_如何学编程at I see in the file generated file my.zip is,

You don't have permission to access "http&#58;&#47;&#47;www&#46;nse&#45;india&#46;com&#47;content&#47;historical&#47;EQUITIES&#47;2002&#47;MAR&#47;cm01MAR2002bhav&#46;csv&#46;zip" on this server.<P>
Reference&#32;&#35;18&#46;7d427b5c&#46;1311889977&#46;25329891

But I'm able to download the file from the website without any problem. What is the reason for this?


You may need to use urllib2 and set the user-agent header to something it recognizes. It might just be blocking anything that doesn't appear to be a normal user.

0

精彩评论

暂无评论...
验证码 换一张
取 消