使用sas和curl下载文件时访问被拒绝错误

时间:2014-03-24 06:30:50

标签: curl sas

我使用下面的sas和curl代码从网上下载文件。

data _null_;
    x "cd c:\sasdata";
    x "curl -O http://nseindia.com/content/indices/histdata/CNX%20NIFTY21-03-2014-21-03-
2014.csv";
run;

文件下载但内容如下

<HTML><HEAD> <TITLE>Access Denied</TITLE> </HEAD><BODY> <H1>Access Denied</H1>

You don't have permission to access "http&#58;&#47;&#47;nseindia&#46;com&#47;content&#47;indices&#47;histdata&#47;CNX&#37;20NIFTY21&#45;03&#45;2014&#45;21&#45;03&#45;2014&#46;csv" on this server.<P> Reference&#32;&#35;18&#46;e5bef75&#46;1395641322&#46;926b13 </BODY> </HTML>

两天前,每件事都很好,但突然发生了上面的错误。

请帮助解决问题。

1 个答案:

答案 0 :(得分:0)

添加用户代理-A "Mozilla"对我有用:

curl -A "Mozilla" http://nseindia.com/content/indices/histdata/CNX%20NIFTY21-03-2014-21-03-2014.csv

它返回:

"Date","Open","High","Low","Close","Shares Traded","Turnover (Rs. Cr)"
"21-Mar-2014","     6515.20","     6522.90","     6485.70","     6493.20","      189854420","         8841.94"