[R] File Downloading Problem
David Winsemius
dwinsemius at comcast.net
Mon Nov 1 16:17:35 CET 2010
On Nov 1, 2010, at 10:41 AM, Duncan Murdoch wrote:
> On 01/11/2010 10:37 AM, Santosh Srinivas wrote:
>> Nope Duncan ... no changes .. the same old way without a proxy ...
>> actually
>> the download.file is being returned "403 forbidden" which is strange.
>>
>> These are just two lines that I am trying to run.
>>
>> sURL<-
>> "http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>> v.csv.zip"
>> download.file(sURL,"test.zip")
>>
>> Put the same URL in a browser and it works fine.
>
> It doesn't work for me, so presumably there is some kind of security
> setting at the site (a cookie?), which allows your browser, but
> doesn't allow you to use R, or me to use anything.
Firefox in a Mac platform will download and unzip the file with no
security complaints and no cookie appears to be set when downloading,
but that code will not access the file, nor will my efforts to wrap
the URL in url() or unz() so it seems more likely that Santosh and I
do not understand the file opening processes that R supports.
> con= unz(description="http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bhav.csv.zip
", file="~/cm01NOV2010bhav.csv")
> test.df <- read.csv(file=con)
Error in open.connection(file, "rt") : cannot open the connection
In addition: Warning message:
In open.connection(file, "rt") :
cannot open zip file 'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bhav.csv.zip'
--
David.
>
> Duncan Murdoch
>
>> -----Original Message-----
>> From: Duncan Murdoch [mailto:murdoch.duncan at gmail.com]
>> Sent: 01 November 2010 19:04
>> To: Santosh Srinivas
>> Cc: 'Rhelp'
>> Subject: Re: [R] File Downloading Problem
>>
>> On 01/11/2010 9:22 AM, Santosh Srinivas wrote:
>> > Dear Group,
>> >
>> > My code stopped working ... used to work till last week!
>> >
>> > sURL<-
>> >
>> "http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>> > v.csv.zip"
>> >
>> > > download.file(sURL,"test.zip")
>> > trying URL
>> >
>> 'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>> > v.csv.zip'
>> > Error in download.file(sURL, "test.zip") :
>> > cannot open URL
>> >
>> 'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>> > v.csv.zip'
>> > In addition: Warning message:
>> > In download.file(sURL, "test.zip") :
>> > cannot open: HTTP status was '403 Forbidden'
>> >
>> > I put the same URL in a browser and it works just fine.
>>
>>
>> Are you using a proxy? If you've recently updated R, you may have
>> told
>> it not to use the proxy. You can test this by running
>>
>> setInternet2(TRUE)
>>
>> (which will use a proxy if one is defined in Internet Explorer) and
>> repeating the download.file() call. You can make Internet2 the
>> default
>> by putting --internet2 on the command line when you start R.
>>
>> Duncan Murdoch
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list