% ...">

Rvest: how can I render a html session webpage in Rstudio?

I have the following code:

library(rvest) s <- html_session("http://had.co.nz") s %>% jump_to("thesis/") s %>% follow_link("vita") 

Now I want to make sure that I clicked on the right web page, how can I render a web page in Rstudio?

+5
source share
1 answer

I provide two ways because I did not get what interests you:

 library(rvest) s <- html_session("http://had.co.nz") t <- s %>% jump_to("thesis/") v <- s %>% follow_link("vita") 

For any of the above t or v you can use the following code to view the HTML code and see if this is correct:

 html(t$url) html(v$url) 

OR after @Mohammad a very useful comment:

 #if you are on windows shell.exec(t$url) shell.exec(v$url) #if you are on mac system(paste("open", t$url)) system(paste("open", v$url)) 

Or a cross-platform option according to @MrFLick's comment:

 browseURL(t$url) browseURL(v$url) 

Actually browse the web page.

(I don't think you can use the Rstudio viewer for non-local web content if that is what you are asking for).

+4
source

All Articles