Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web scraping web刮取后不显示的数据列(rvest和xlsx)_Web Scraping_Xlsx_Rvest - Fatal编程技术网

Web scraping web刮取后不显示的数据列(rvest和xlsx)

Web scraping web刮取后不显示的数据列(rvest和xlsx),web-scraping,xlsx,rvest,Web Scraping,Xlsx,Rvest,我目前正在尝试下载公共财政数据,在设置我的刮取时,我只拉取日期列、20年列和外推因子。10年栏,位于桌子中间,不包括在Excel中的粘贴和粘贴。我的代码如下。不包括目录 url <- "https://www.treasury.gov/resource-center/data-chart-center/interest- rates/Pages/TextView.aspx?data=longtermrateYear&year=2020" ten_year_comp

我目前正在尝试下载公共财政数据,在设置我的刮取时,我只拉取日期列、20年列和外推因子。10年栏,位于桌子中间,不包括在Excel中的粘贴和粘贴。我的代码如下。不包括目录

url <- "https://www.treasury.gov/resource-center/data-chart-center/interest- 
        rates/Pages/TextView.aspx?data=longtermrateYear&year=2020"
ten_year_comp <- read_html(url, encoding = "table") 
ten_year_comp %>%
   html_nodes("table") %>%
   .[[4]] %>%
   html_table(fill = TRUE) %>%

write.xlsx(ten_year_comp, file = "TREASURY10YR.xlsx", sheetName = "ten_year_comp", 
           col.names = TRUE, row.names = TRUE, asTable = TRUE, append = FALSE)
url%
.[[4]] %>%
html_表格(fill=TRUE)%>%
write.xlsx(十年公司,file=“TREASURY10YR.xlsx”,sheetName=“十年公司”,
col.names=TRUE,row.names=TRUE,asTable=TRUE,append=FALSE)
url
url <- "https://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=longtermrateYear&year=2020"

ten_year_comp <- html_nodes(read_html(url), "table")[[4]] %>% html_table(fill = T)

write.xlsx(
  ten_year_comp,
  file = "TREASURY10YR.xlsx",
  sheetName = "ten_year_comp",
  col.names = TRUE,
  row.names = TRUE,
  asTable = TRUE,
  append = FALSE
)