首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用R抓取实时更新信息

使用R抓取实时更新信息
EN

Stack Overflow用户
提问于 2020-03-30 12:54:10
回答 1查看 84关注 0票数 0

我对网络抓取很陌生,我一直在努力搜集英国地方政府的右侧名单和新冠肺炎案件的数量。

以下是网站:https://www.arcgis.com/apps/opsdashboard/index.html#/f94c3c90da5b4e9f9a0b19484dd4bb14

我已经能够刮维基百科,但我不知道从哪里开始从上面的网站。任何提示/链接都将是非常有用和非常感谢的!

EN

回答 1

Stack Overflow用户

发布于 2022-10-10 00:16:54

通过以下代码,我在页面中获得了一些数字:

代码语言:javascript
复制
library(rvest)
library(RSelenium)

port <- as.integer(4444L + rpois(lambda = 1000, 1))
rd <- rsDriver(chromever = "105.0.5195.52", browser = "chrome", port = port)
remDr <- rd$client
remDr$open()

url <- "https://coronavirus.data.gov.uk/"
remDr$navigate(url)
html_Content <- remDr$getPageSource()[[1]]
text <- read_html(html_Content) %>% html_text2()
text <- strsplit(text, "\n")[[1]]

text[54 : 72]
 [1] "Last 7 days – first dose"                                                                            
 [2] "10,536Number of people vaccinated (first dose) in the 7 days to 2 October 2022"                      
 [3] "Total – first dose"                                                                                  
 [4] "45,275,970Total number of people vaccinated (first dose) reported on 2 October 2022"                 
 [5] "Last 7 days – second dose"                                                                           
 [6] "18,800Number of people vaccinated (second dose) in the 7 days to 2 October 2022"                     
 [7] "Total – second dose"                                                                                 
 [8] "42,718,917Total number of people vaccinated (second dose) reported on 2 October 2022"                
 [9] "Last 7 days – booster or third dose"                                                                 
[10] "25,518Number of people vaccinated (booster or third dose) in the 7 days to 2 October 2022"           
[11] "Total – booster or third dose"                                                                       
[12] "33,613,297Total number of people vaccinated (booster or third dose) reported on 2 October 2022"      
[13] "Percentage of population aged 12+"                                                                   
[14] "93.6%Percentage of population aged 12+ vaccinated (first dose) reported on 2 October 2022"           
[15] "First dose"                                                                                          
[16] "88.3%Percentage of population aged 12+ vaccinated (second dose) reported on 2 October 2022"          
[17] "Second dose"                                                                                         
[18] "69.5%Percentage of population aged 12+ vaccinated (booster or third dose) reported on 2 October 2022"
[19] "Booster or third dose" 

我希望这是有帮助的!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60930990

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档