rvest - Saving Multiple Html Sources in R -


i have created following code

library('xml') library('rvest')  links <- c('https://www.google.com/',             'https://www.youtube.com/?gl=us',             'https://news.google.com/news/u/0/headlines?hl=en&ned=us')  (i in 1:3){   html_object <- read_html(links[i])   write_xml(html_object, file="test.html") } 

i want save of these files html files, current code saving one. guessing keeps rewriting same file 3 times example. how make not rewrite same file? ideally, file name these html files url link, unable figure out how multiple links. example, end result should 3 html files titled 'https://google.com/', 'https://www.youtube.com/?gl=us', , 'https://news.google.come/news/u/0/headlines?h1-en&ned=us'.

what using paste0() create filename in for-loop?

for(i in 1:length(links)){   html_object  <- read_html(links[i])   somefilename <- paste0("filename_", i, ".html")   write_xml(html_object, file = somefilename) } 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -