-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pagination #8
Comments
The big question is how to handle failures — otherwise I think we could provide some helpers similar to what I did in https://github.com/ropensci/rtweet/blob/master/R/http.R#L105 and https://github.com/ropensci/rtweet/blob/master/R/http.R#L178 (but with more thought around the callbacks). |
Maybe this is special case of general spidering problem — build queue and have callback to add new urls/requests to queue. next_page <- function(req, resp) {
req %>% req_url_query(cursor = resp_get_header(resp, "Next-Cursor"))
}
req %>% req_paginate(next_page) Also need Possible to know total number of pages without knowing what request corresponds to each page. Would return a list of responses and would be user's responsibility to handle. May want to allow some specialised error handling so that if it occurs after the first page, you still get the interim results (with a warning). Also related to #18. |
multi_req_paginate <- function(req, next_page, n_pages = NULL) {
out <- vector("list", n_pages %||% 10)
i <- 1L
repeat({
out[[i]] <- req_perform(req)
if (!is.null(n_pages) && i == n_pages) {
break
}
req <- next_page(req, out[[i]])
if (is.null(req)) {
break
}
i <- i + 1L
if (i > length(out)) {
length(out) <- length(out) * 2L
}
})
if (i != length(out)) {
out <- out[seq_len(i)]
}
out
} |
Would like to give me +1 to built in pagination. Would be very nice :) |
I'm wondering if we couldn't generalise the |
I think you already get that from the |
Closed by #279. |
Help with auto-traversal, as we do in gh. There are some pretty standard ways of doing this.
The text was updated successfully, but these errors were encountered: