我想从httr包
获取带有r GET函数的hashtag的urlhttr::GET("https://en.wikipedia.org/wiki/Kona_Lanes#Peak_years")
但是只返回hashtag之前的url。
另一个例子如下。 “第一”和“第二”页面的结果是
library(httr)
url1 = "example.com"
url2 = "example.com#foo=bar"
res1 <- htmlTreeParse(GET(paste("https://www.",url1,sep="") ),useInternalNodes = TRUE)
res2 <- htmlTreeParse(GET(paste("https://www.",url2,sep="")),useInternalNodes = TRUE)
答案 0 :(得分:0)
use %23 where # is present in URL
HTTR :: GET( “https://en.wikipedia.org/wiki/Kona_Lanes%23Peak_years”)
答案 1 :(得分:0)
什么不起作用和/或你期望与片段标识符有什么不同呢?没有它?
library(httr)
library(purrr)
res1 <- httr::GET("https://en.wikipedia.org/wiki/Kona_Lanes#Peak_years")
res2 <- httr::GET("https://en.wikipedia.org/wiki/Kona_Lanes%23Peak_years")
res3 <- httr::GET("https://en.wikipedia.org/wiki/Kona_Lanes")
txt1 <- content(res1, as="text")
txt2 <- content(res2, as="text")
txt3 <- content(res3, as="text")
identical(txt1, txt2)
## [1] TRUE
identical(txt2, txt3)
## [1] TRUE
identical(txt1, txt3)
## [1] TRUE