[R] postForm() in RCurl and library RHTMLForms

Santosh Srinivas santosh.srinivas at gmail.com
Thu Nov 4 16:15:15 CET 2010


I don’t have the implementation in the way you want it 
. Sorry 
 but
someone here will definitely know

The group showed me to do it this way though 
.

library(zoo)
library("RCurl")

sNiftyURL =
"http://nseindia.com/content/indices/histdata/S&P%20CNX%20NIFTY01-01-2000-02
-11-2010.csv"
Nifty_Dat = getURLContent(sNiftyURL, verbose = TRUE, useragent =
getOption("HTTPUserAgent"))
tblNifty <- read.csv(textConnection(Nifty_Dat))
tblNifty <- subset(tblNifty,select=c(Date,Close))
tblNifty$Date <- as.Date(tblNifty$Date, format ="%d-%b-%Y")
tblNifty <-read.zoo((tblNifty))
closeAllConnections()

HTH.
S

From: sayan dasgupta [mailto:kittudg at gmail.com] 
Sent: 04 November 2010 15:09
To: r-help at r-project.org
Cc: duncan at wald.ucdavis.edu; santosh.srinivas at gmail.com
Subject: postForm() in RCurl and library RHTMLForms

Hi RUsers,

Suppose I want to see the data on the website 
url <- "http://www.nseindia.com/content/indices/ind_histvalues.htm"

for the index "S&P CNX NIFTY" for
dates "FromDate"="01-11-2010","ToDate"="02-11-2010"

then read the html table from the page using readHTMLtable()

I am using this code 
webpage <- postForm(url,.params=list(
                       "FromDate"="01-11-2010",
                       "ToDate"="02-11-2010",
                       "IndexType"="S&P CNX NIFTY",
                       "Indicesdata"="Get Details"),
                 .opts=list(useragent = getOption("HTTPUserAgent")))

But it doesn't give me desired result 

Also I was trying to use the function getHTMLFormDescription from the
package RHTMLForms but there we can't use the argument 
.opts=list(useragent = getOption("HTTPUserAgent")) which is needed for this
particular website 


Thanks and Regards
Sayan Dasgupta



More information about the R-help mailing list