我想在www.apptrace.com中抓取应用程序的id,但是当我执行这段代码时,我得到了一个NA值列表
library(rvest)
URL <- read_html("https://www.apptrace.com")
Identifiant=html_nodes(URL, "#playstore_topchart.topcharts.table .cell.linked.app_cell ") %>% html_attr('id')
发布于 2020-11-30 21:06:45
您正在读取的特定节点没有名为id的属性。它们包含一些带有class = "id"的div,并且它们具有id属性。
您可以使用xpath获取节点,如下所示:
html_nodes(URL, xpath = "//div[@class='id']") %>% html_attr("id")
#> [1] "363590051" "479516143"
#> [3] "544007664" "586447913"
#> [5] "1330123889" "1105855019"
#> [7] "284882215" "553834731"
#> [9] "835599320" "507874739"
#> [11] "333710667" "587366035"
#> [13] "525818839" "1261357853"
#> [15] "664575829" "com.facebook.orca"
#> [17] "com.facebook.katana" "com.zhiliaoapp.musically"
#> [19] "ch.threema.app" "com.instagram.android"
#> [21] "com.whatsapp" "com.google.android.play.games"
#> [23] "com.viber.voip" "video.like"
#> [25] "com.tocaboca.tocahairsalon3" "com.maxmpz.audioplayer.unlock"
#> [27] "us.zoom.videomeetings" "org.prowl.torque"
#> [29] "org.telegram.messenger" "com.picsart.studio"https://stackoverflow.com/questions/65071174
复制相似问题