我正在尝试使用package从http://www.federalreserve.gov/apps/mdrm/data-dictionary抓取数据。我可以成功填写并提交第一个表格,但是在有第二个表格的情况下(例如,如果您搜索系列“RCON”,您会得到:“您选择了一个带有分段助记符的系列”),同样方法不起作用。R
RHTMLForms
我的代码如下:
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")
这给出了一个Error in Function: Could not resolve host: NA
.
我还注意到,它提供了一个在浏览器中无法访问getHTMLFormDescription(results.html)[[1]]
的网址http://www.federalreserve.gov/apps/mdrm/data-dictionary/search/series 。我该如何解决这个问题?