Save Images via rvest

I would like to save all XL png files in a website via rvest. However the image can not be opened.

library(tidyverse)
s <- html_session("https://www.countryflags.com/en/china-flag-image.html")

imgsrc <- s %>%
  read_html() %>%
  html_nodes(xpath = "//*/a[@href='//cdn.countryflags.com/download/china/flag-png-xl.png']") %>% 
  html_attr('href')
img <- jump_to(s, imgsrc)
writeBin(img$response$content, basename(imgsrc))  

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.