Skip to content

Download a file from url

9 messages · Rui Barradas, veepsirtt, Brian Ripley +1 more

#
Hi

Download the xls file from this link
http://www.nseindia.com/content/fo/fii_stats_12-Oct-2012.xls
<http://www.nseindia.com/content/fo/fii_stats_12-Oct-2012.xls>  

I tried this
---------------------------------------------------------------
 library(XLConnect)
url = "http://www.nseindia.com/content/fo/fii_stats_12-Oct-2012.xls"
local.xls.file = tempfile()
download.file(url, local.xls.file)
wb = loadWorkbook(local.xls.file, create=F)
data = readWorksheet(wb, sheet=1)
View(data)
---------------------------------------------------------------
no results ...
kindly help me
thanks
veepsirtt




--
View this message in context: http://r.789695.n4.nabble.com/Download-a-file-from-url-tp4642985p4646215.html
Sent from the R help mailing list archive at Nabble.com.
#
Hello,

Your page returns "access denied":

library(RCurl)

url <- "http://www.nseindia.com/content/fo/fii_stats_12-Oct-2012.xls"
xls <- getURL(url)
cat(xls)
<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>

You don't have permission to access 
"http&#58;&#47;&#47;www&#46;nseindia&#46;com&#47;content&#47;fo&#47;fii&#95;stats&#95;12&#45;Oct&#45;2012&#46;xls" 
on this server.<P>
Reference&#32;&#35;18&#46;f0241c2&#46;1350314817&#46;23d7e0e0
</BODY>
</HTML>

Also, start a new thread when you want to ask a new question.

Hope this helps,

Rui Barradas
Em 15-10-2012 09:57, veepsirtt escreveu:
#
Mr Jeffrey Breen
 mailed me the following code.
but it is not giving me the results under Windows 7.

With regards
veepsirtt'

library(XLConnect) 

url = "http://www.nseindia.com/content/fo/fii_stats_12-Oct-2012.xls" 
local.xls.file = tempfile() 

download.file(url, local.xls.file, method='wget', extra="-U 'Mozilla/5.0
(X11; Linux) Gecko Firefox/5.0'") 
wb = loadWorkbook(local.xls.file, create=F) 
data = readWorksheet(wb, sheet=1) 



--
View this message in context: http://r.789695.n4.nabble.com/Download-a-file-from-url-tp4642985p4646252.html
Sent from the R help mailing list archive at Nabble.com.
#
You didn't say what errors you've got but you probably wants to
specify argument mode="wb" in your download.file() call, cf.
https://stat.ethz.ch/pipermail/r-devel/2012-August/064739.html

/Henrik
On Mon, Oct 15, 2012 at 1:57 AM, veepsirtt <veepsirtt at gmail.com> wrote:
#
On 16/10/2012 02:33, veepsirtt wrote:
But it is.  You need the programs wget or curl installed and in your 
path: pre-compiled versions for Windows are available if you look.
PLEASE do: you have lost all the context here: you are posting to R-help 
and not to Nabble.
#
Hello Prof Brian Ripley
I installed wget for windows from  http://users.ugent.be/~bpuype/wget/
<http://users.ugent.be/~bpuype/wget/>   and got the results
very thanks
veepsirtt
--------------------------------------------------------------------------------------------------------------------------------------------------
--2012-10-16 14:44:36--  http://(x11;/
Resolving (x11;... failed: Unknown host.
wget: unable to resolve host address `(x11;'
--2012-10-16 14:44:36--  http://linux)/
Resolving linux)... failed: Unknown host.
wget: unable to resolve host address `linux)'
--2012-10-16 14:44:36--  http://gecko/
Resolving gecko... failed: Unknown host.
wget: unable to resolve host address `gecko'
--2012-10-16 14:44:36--  http://firefox/5.0'
Resolving firefox... failed: Unknown host.
wget: unable to resolve host address `firefox'
--2012-10-16 14:44:37-- 
http://www.nseindia.com/content/fo/fii_stats_12-Oct-2012.xls
Resolving www.nseindia.com... 124.124.252.97, 124.124.252.107
Connecting to www.nseindia.com|124.124.252.97|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 24576 (24K) [application/vnd.ms-excel]
Saving to: `C:/Users/Acer/AppData/Local/Temp/Rtmpqa0fd0/file1828c40257e'

     0K .......... .......... ....                            100%
5.26K=4.6s

2012-10-16 14:44:44 (5.26 KB/s) -
`C:/Users/Acer/AppData/Local/Temp/Rtmpqa0fd0/file1828c40257e' saved
[24576/24576]

FINISHED --2012-10-16 14:44:44--
Downloaded: 1 files, 24K in 4.6s (5.26 KB/s)
FII.DERIVATIVES.STATISTICS.FOR.12.Oct.2012     Col1           Col2    
Col3
3                              INDEX FUTURES  40230.0 1142.001965025 
51478.0
4                              INDEX OPTIONS 525745.0      14990.371
492126.0
5                              STOCK FUTURES  35248.0    1028.378075 
45162.0
6                              STOCK OPTIONS 105001.0    3212.669375
105553.0
            Col4      Col5           Col6
3 1430.472715225  603867.0  15419.5277629
4    14070.52175 1783758.0 50627.34217375
5   1308.1875375 1041481.0  30630.1147675
6    3230.074875   80391.0 2505.014379375
-----------------------------------------------------------------------------------------------------------------------------





--
View this message in context: http://r.789695.n4.nabble.com/Download-a-file-from-url-tp4642985p4646313.html
Sent from the R help mailing list archive at Nabble.com.
#
Have you tried downloading it manually using a web browser or similar?
 If so, compare that downloaded file to that you get from
download.file() and see if they're the same.  If the same, the problem
is elsewhere (which is not unlikely to be the case). /H
On Mon, Oct 15, 2012 at 6:15 PM, veepsirtt <veepsirtt at gmail.com> wrote: