【发布时间】:2017-11-06 14:34:08
【问题描述】:
从网页抓取数据时,某些元素/值不会返回。
具体来说,我是用rvest包报废的。
包含我想要的信息的网页是https://azure.microsoft.com/en-us/pricing/details/virtual-machines/windows/ - 但是,当我废弃数据时,带有价格的列只返回“$-”。
示例代码:
library(rvest)
webpage <- read_html("https://azure.microsoft.com/en-us/pricing/details/virtual-machines/windows/")
tbls <- html_nodes(webpage, "table")
tbls_ls <- webpage %>%
html_nodes("table") %>%
.[1:(length(tbls)-2)] %>%
html_table()
第一个df的输出:
> List of 22 $ :'data.frame': 7 obs. of 6 variables: ..$ Instance
> : chr [1:7] "B1L" "B1S" "B2S" "B1MS" ... ..$ Cores
> : int [1:7] 1 1 2 1 2 4 8 ..$ RAM
> : chr [1:7] "0.50 GiB" "1.00 GiB" "4.00 GiB" "2.00 GiB" ... ..$
> Temporary Storage : chr [1:7] "1 GiB" "2
> GiB" "8 GiB" "4 GiB" ... ..$ Price
> : chr [1:7] "$-" "$-" "$-" "$-" ... ..$ Prices with Azure Hybrid
> Benefit1 (% savings): chr [1:7] "$-" "$-" "$-" "$-" ...
我可以做些什么来获得这些特定元素的全部价值?
【问题讨论】:
标签: html r dataframe web-scraping missing-data