How to publish in rvest html_session?

How can I post "inside" an html session?

So, after I opened the session through a <- rvest::html_session(url)

I tried:

 library(httr) POST(path, add_headers(setNames(as.character(headers(a)), names(headers(a)))), set_cookies(setNames(cookies(a)$value, cookies(a)$name)), body = list(...), encode = "json") 

But this processes my request as I have not been registered. Any suggestions? I am looking for something like POST(session, path, body, ...)

0
source share
1 answer

Well, after some deepening into it, I solved it using:

 x %>% rvest:::request_POST(url, config(referer = x$url), user_agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.86 Safari/537.36"), body = list(...), encode = "form") 

Where rvest:::request_POST internally uses

 httr::POST(url, x$config, ..., handle = x$handle) 
+2
source

Source: https://habr.com/ru/post/1259003/


All Articles