等待JSON API在没有Docker的情况下加载

等待JSON API在没有Docker的情况下加载,r,json,web-scraping,R,Json,Web Scraping,我试图使用R和jsonlite从一个政府网站抓取JSON数据,但它并没有抓取所有内容,我认为这是因为网页没有加载。我认为这是因为它刚好刮了1000行,尽管我认为大约有32000行。简单代码: library(jsonlite) url <- 'https://data.medicare.gov/resource/rmgi-5fhi.json' hcahps <- fromJSON(url) library(jsonlite) url这应该可以帮助你开始。它是Socrata AP

我试图使用R和
jsonlite
从一个政府网站抓取JSON数据,但它并没有抓取所有内容,我认为这是因为网页没有加载。我认为这是因为它刚好刮了1000行,尽管我认为大约有32000行。简单代码:

library(jsonlite)

url <- 'https://data.medicare.gov/resource/rmgi-5fhi.json'

hcahps <- fromJSON(url)
library(jsonlite)

url这应该可以帮助你开始。它是Socrata API服务器,因此需要一些帮助:

library(RSocrata)

xdf <- RSocrata::read.socrata("https://data.medicare.gov/resource/rmgi-5fhi.json")

dim(xdf)
## [1] 263890     28

dplyr::glimpse(xdf)
## Observations: 263,890
## Variables: 28
## $ address                               <chr> "911 NORTHLAND DR", "5360 WEST CREOLE HWY", "6000 S...
## $ city                                  <chr> "PRINCETON", "CAMERON", "LOS ANGELES", "HOUSTON", "...
## $ county_name                           <chr> "SHERBURNE", "CAMERON", "LOS ANGELES", "HARRIS", "H...
## $ hcahps_answer_description             <chr> "Room was \"always\" clean", "\"Always\" quiet at n...
## $ hcahps_answer_percent                 <chr> "83", "Not Available", "Not Applicable", "Not Appli...
## $ hcahps_linear_mean_value              <chr> "Not Applicable", "Not Applicable", "Not Available"...
## $ hcahps_measure_id                     <chr> "H_CLEAN_HSP_A_P", "H_QUIET_HSP_A_P", "H_HSP_RATING...
## $ hcahps_question                       <chr> "Patients who reported that their room and bathroom...
## $ hospital_name                         <chr> "FAIRVIEW NORTHLAND REGIONAL HOSPITAL", "SOUTH CAME...
## $ location.type                         <chr> "Point", "Point", "Point", NA, "Point", "Point", "P...
## $ location.coordinates                  <list> [<-93.58893, 45.55888>, <-93.16524, 29.80717>, <-1...
## $ location_address                      <chr> "911 NORTHLAND DR", "5360 WEST CREOLE HWY", "6000 S...
## $ location_city                         <chr> "PRINCETON", "CAMERON", "LOS ANGELES", "HOUSTON", "...
## $ location_state                        <chr> "MN", "LA", "CA", "TX", "IN", "OH", "WI", "MI", "WA...
## $ location_zip                          <chr> "55371", "70631", "90036", "77004", "46037", "45662...
## $ measure_end_date                      <dttm> 2017-06-30, 2017-06-30, 2017-06-30, 2017-06-30, 20...
## $ measure_start_date                    <dttm> 2016-07-01, 2016-07-01, 2016-07-01, 2016-07-01, 20...
## $ number_of_completed_surveys           <chr> "406", "Not Available", "53", "FEWER THAN 50", "280...
## $ patient_survey_star_rating            <chr> "Not Applicable", "Not Applicable", "Not Applicable...
## $ phone_number                          <chr> "7633896481", "3375424111", "3239301040", "71352868...
## $ provider_id                           <chr> "240141", "190307", "050751", "450797", "150181", "...
## $ state                                 <chr> "MN", "LA", "CA", "TX", "IN", "OH", "WI", "MI", "WA...
## $ survey_response_rate_percent          <chr> "31", "Not Available", "31", "32", "27", "39", "34"...
## $ zip_code                              <chr> "55371", "70631", "90036", "77004", "46037", "45662...
## $ hcahps_answer_percent_footnote        <chr> NA, "1 - The number of cases/patients is too few to...
## $ number_of_completed_surveys_footnote  <chr> NA, "1 - The number of cases/patients is too few to...
## $ survey_response_rate_percent_footnote <chr> NA, "1 - The number of cases/patients is too few to...
## $ patient_survey_star_rating_footnote   <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,...
库(RSocrata)
xdf