I'm having some trouble with the following code:
state <- read_html("https://www.state.gov/covid-19-recovery/vaccine-deliveries/")
As I receive the following error: Error in open.connection(x, "rb") : HTTP error 403.
This code has always worked for me before and works on another laptop but not my primary laptop so I know I messed something up. Any ideas would be much appreciated. Thank you!
CodePudding user response:
You could bypass that with polite
library(tidyverse)
library(rvest)
#>
#> Attaching package: 'rvest'
#> The following object is masked from 'package:readr':
#>
#> guess_encoding
library(polite)
page <- "https://www.state.gov/covid-19-recovery/vaccine-deliveries/" %>%
bow() %>%
scrape()
page %>%
html_elements(".tadv-color") %>%
html_text2() %>%
pluck(2) %>%
parse_number()
#> [1] 682437530
Created on 2023-01-07 with reprex v2.0.2