tidyverse / rvest

Simple web scraping for R
https://rvest.tidyverse.org
Other
1.49k stars 341 forks source link

Navigating back then forward isn't a round trip #313

Closed cwickham closed 3 years ago

cwickham commented 3 years ago

session_back() followed by session_forward() doesn't get you back to the original URL, see example below. I think I have a fix, I'll open a PR.

Create a history of two URLs:

library(rvest)
s <- session("http://hadley.nz/")
s <- session_jump_to(s, "hadley-wickham.jpg")
session_history(s)
#>   http://hadley.nz/
#> - http://hadley.nz/hadley-wickham.jpg

Should get me back to http://hadley.nz/hadley-wickham.jpg, shouldn’t it?

s %>% session_back() %>% session_forward() 
#> <session> http://hadley.nz/
#>   Status: 200
#>   Type:   text/html
#>   Size:   9090

Created on 2021-02-19 by the reprex package (v0.3.0)