Hello,
I used to use crrri in the past and it worked well. Now I'm running a function written with it after some time and I get the following error:
cannot open URL 'http://localhost:9222/json/new': HTTP status was '405 Method Not Allowed'
My function is the following:
get_website_resources <- function(url, url_filter = ".*", type_filter = ".*",
wait_for = 20,
n_of_resources = NULL, interactive = FALSE) {
# Silence CMD CHECK about non standard eval
. <- NULL
crrri::perform_with_chrome(function(client) {
Fetch <- client$Fetch
Page <- client$Page
if (interactive) client$inspect()
out <- new.env()
out$results <- list()
out$resolve_function <- NULL
out$pr <- promises::promise(function(resolve, reject) {
out$resolve_function <- resolve
Fetch$enable(patterns = list(list(urlPattern = "*", requestStage = "Response"))) %...>%
{
Fetch$requestPaused(callback = function(params) {
if (stringr::str_detect(params$request$url, url_filter) & stringr::str_detect(params$resourceType, type_filter)) {
Fetch$getResponseBody(requestId = params$requestId) %...>% {
resp <- .
if (resp$body != "") {
if (resp$base64Encoded) resp$body <- jsonlite::base64_dec(resp$body) %>% rawToChar()
body <- list(list(
url = params$request$url,
response = resp
)) %>% setNames(params$requestId)
# str(body)
out$results <- append(out$results, body)
if (!is.null(n_of_resources) & length(out$results) >= n_of_resources) out$resolve_function(out$results)
}
}
}
Fetch$continueRequest(requestId = params$requestId)
})
} %...>%
{
Page$navigate(url)
} %>%
crrri::wait(wait_for) %>%
crrri::then(~ out$resolve_function(out$results))
})
out$pr$then(function(x) x)
}, timeouts = max(wait_for + 3, 30), cleaning_timeout = max(wait_for + 3, 30))
}
it is run like this:
get_website_resources(
url = "https://ieeexplore.ieee.org/search/searchresult.jsp?queryText=Adversarial%20machine%20learning&rowsPerPage=100&ranges=2020_2020_Year",
url_filter = "rest/search",
type_filter = "XHR", wait_for = 20
)
I used it the last time successfully a couple of years ago
Hello,
I used to use crrri in the past and it worked well. Now I'm running a function written with it after some time and I get the following error:
cannot open URL 'http://localhost:9222/json/new': HTTP status was '405 Method Not Allowed'My function is the following:
it is run like this:
I used it the last time successfully a couple of years ago