【发布时间】:2017-04-24 16:13:39
【问题描述】:
我正在尝试从site 中提取失业率数据。在表单中,有一个带有一些选项的select 标签。我可以从默认年份 2007 到 2017 中提取表格。但是我很难为from_year 和to_year 设置一个值。这是我到目前为止的代码:
session = html_session("https://data.bls.gov/timeseries/LNS14000000")
form = read_html("https://data.bls.gov/timeseries/LNS14000000") %>% html_node("table form") %>% html_form()
set_values(form, from_year = 2000, to_year = as.numeric(format(Sys.Date(), "%Y"))) # nothing happened if I set the value for years
submit_form(session, form)
它没有按预期工作。
【问题讨论】:
-
如果不使用
RSelenium之类的东西,我认为您无法做到这一点。看这里的例子...stackoverflow.com/questions/43307090/… 但是,我注意到在这种情况下 bls 有一个 API,所以这可能值得先看看...bls.gov/developers