Many thanks Ista. I will try other routes as well.
Thanks Jeff and sorry for posting without abiding by the rules.
Thanks James. I would rather automate this than download manually
everytime. That is my intent.

Best
Balaji


On Tue, Jul 15, 2014 at 7:16 PM, Ista Zahn <istaz...@gmail.com> wrote:

> Not an R question, but see
> https://addons.mozilla.org/en-US/firefox/addon/cliget/ for an easy way
> to see what what is going on under the hood when you download using
> firefox. For your example I get
>
> wget --header='Host: www.nseindia.com' --header='User-Agent:
> Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0'
> --header='Accept:
> text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
> --header='Accept-Language: en-US,en;q=0.5' --header='Connection:
> keep-alive' '
> http://www.nseindia.com/content/historical/DERIVATIVES/2014/JUL/fo09JUL2014bhav.csv.zip
> '
> -O 'fo09JUL2014bhav.csv.zip' -c
>
> Now you just need to translate that to R. (Or not, sometimes its
> easier to just shell out (using e.g., 'system()' ) and download with
> wget or curl).
>
> Best,
> Ista
>
> On Tue, Jul 15, 2014 at 11:24 AM, Electron Musketeer
> <muskete...@gmail.com> wrote:
> > Dear Experts
> >
> > I am new to this forum and to R and was trying the following to access a
> > zip file from  the webpages of the NSE. Here is my code.
> >
> > temp <- tempfile()
> > download.file("
> >
> http://www.nseindia.com/content/historical/DERIVATIVES/2014/JUL/fo09JUL2014bhav.csv.zip
> > ",temp)
> > con <- unz(temp, "a1.dat")
> > data <- matrix(scan(con),ncol=4,byrow=TRUE)
> > unlink(temp)
> >
> >
> > The result is:
> > cannot open URL '
> >
> http://www.nseindia.com/content/historical/DERIVATIVES/2014/JUL/fo09JUL2014bhav.csv.zip
> > '
> > In addition: Warning message:
> > In download.file("
> >
> http://www.nseindia.com/content/historical/DERIVATIVES/2014/JUL/fo09JUL2014bhav.csv.zip
> ",
> >  :
> >   cannot open: HTTP status was '403 Forbidden'
> >
> >
> > I tried accessing this file directly from the website and it is letting
> me
> > access it. My question is why is it not letting me download from R? I
> have
> > gone through some websites to see if this has been resolved but the older
> > resolutions also do not work. Can someone help please?
> >
> > Thx
> > Balaji
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to