guox at ucalgary.ca
2009-Jun-30 20:32 UTC
[R] How to pass parameters to htmlParse Bank of Canada html pages
To get USDCAD rates from Bank of Canada, we first go url <- "http://banqueducanada.ca/en/rates/exchange-avg.html" select 12 months for Rates for the past and click "Get Rates" button. Then the page moves to address <- "http://banqueducanada.ca/cgi-bin/famecgi_fdps" and the rates show in the html page. htmlParse() can read the html document but htmlParse(address) did not work since we need to pass the selected field value and clicking Get Rates button event parameters to http://banqueducanada.ca/en/rates/exchange-avg.html. I was wondering if you know how to load in data from such html pages. Thanks, -james
Barry Rowlingson
2009-Jun-30 20:51 UTC
[R] How to pass parameters to htmlParse Bank of Canada html pages
On Tue, Jun 30, 2009 at 9:32 PM, <guox at ucalgary.ca> wrote:> To get USDCAD rates from Bank of Canada, we first go > > url <- "http://banqueducanada.ca/en/rates/exchange-avg.html" > > select 12 months for Rates for the past and click "Get Rates" button. Then > the page moves to > > address <- "http://banqueducanada.ca/cgi-bin/famecgi_fdps" > > and the rates show in the html page. > > htmlParse() can read the html document but > htmlParse(address) did not work since we need to pass the selected field > value and clicking Get Rates button event parameters to > http://banqueducanada.ca/en/rates/exchange-avg.html. > I was wondering if you know how to load in data from such html pages. Thanks, >I'm not sure what package your htmlParse comes from... Anyway, it seems you want to be able to send form data via a POST request - use postForm in the RCurl package. That should set you in the right direction. Barry