klamsi,该URL指向一个HTML文件,该文件被重命名为扩展名为“.xls”。这在网站管理员中有点常见。通过将扩展名“.xls”重命名为“.html”,自己尝试一下。
第二个问题是HTML的表配置非常混乱。兴趣表是文档中的第五个表。
这是一个获得总体人口值的解决方案(或“范围A7:B37,I7:K37”)。
url <- "http://iambweb.ams.or.at/ambweb/showcognusServlet?tabkey=3643193®ionDisplay=%C3%96sterreich&export=html&outputLocale=en"
df <- read_html(url) %>%
html_table(header = TRUE, fill = TRUE) %>%
.[[5]] %>% #Extract the fifth table in the list
as.data.frame() %>%
.[,c(1:11)] %>%
select(1:2, 9:11)
names <- unlist(df[1,])
names[1:2] <- c("item", "Bundesland")
colnames(df) <- names
df <- df[-1,]
df %>% head()
item Bundesland Bestand Veränderung zum VJ absolut Veränderung zum VJ in %
2 Arbeitslosigkeit Bgld 7119 -973 -0.120242214532872
3 Arbeitslosigkeit Ktn 16564 -2160 -0.115359965819269
4 Arbeitslosigkeit NÃ 46342 -6095 -0.116234719758949
5 Arbeitslosigkeit OÃ 29762 -4649 -0.135102147569091
6 Arbeitslosigkeit Sbg 11173 -643 -0.0544177386594448
7 Arbeitslosigkeit Stmk 28677 -5602 -0.1634236704688