I'm trying to scrape data from http://www.federalreserve.gov/apps/mdrm/data-dictionary using R
package RHTMLForms
. I can successfully fill out and submit the first form but, in the cases where there is a second form (e.g., if you search for series "RCON", you get: "You have selected a series with segmented mnemonics"), the same approach doesn't work.
My code is below:
library(RHTMLForms)
library(RCurl)
library(XML)
mdrm.form = getHTMLFormDescription("http://www.federalreserve.gov/apps/mdrm/data-dictionary")[[1]]
fun = createFunction(mdrm.form)
results.html = fun(
DisplayConfidentialItemsOnly = NULL,
DisplayItemShortTitle = NULL,
Keyword = "RCON",
search_by = "Series",
SelectedCatalogItemDayCeilingRange.Key = "18",
SelectedCatalogItemDayRange.Key = "18",
SelectedCatalogItemMonthCeilingRange.Key = "Mar",
SelectedCatalogItemMonthRange.Key = "Mar",
SelectedCatalogItemReportingStatus.Key = "All",
SelectedCatalogItemState.Key = "Opened",
SelectedCatalogItemTimePeriod.Key = "Before",
SelectedCatalogItemYearCeilingRange.Key = "2015",
SelectedCatalogItemYearRange.Key = "2015",
SelectedItemType.Key = "None",
SelectedReportForm.Key= "Select Reporting Form",
SelectedSeries.Key = "RCON"
)
fun2 = createFunction(getHTMLFormDescription(results.html)[[1]])
results2.html = fun2(SelectedSeries.Key = "RCON")
This gives an Error in Function: Could not resolve host: NA
.
I also noticed that getHTMLFormDescription(results.html)[[1]]
gives a url http://www.federalreserve.gov/apps/mdrm/data-dictionary/search/series which is not accessible in the browser. How can I resolve this?