wikkitidy (version 0.1.12)

get_query_results: Perform a query using the MediaWiki Action API

Description

next_result() sends exactly one request to the server.

next_batch() requests results from the server until data is complete the latest batch of pages in the result.

retrieve_all() keeps requesting data until all the pages from the query have been returned.

Usage

next_result(x)

next_batch(x)

retrieve_all(x)

Value

A query_tbl containing results of the query. If x is a query_tbl, then the function will return a new data with the new data appended to it. If x is a wiki_action_request, then the returned query_tbl will contain the necessary data to supply future calls to next_result(), next_batch() or retrieve_all().

Arguments

x

The query. Either a wiki_action_request or a query_tbl.

Details

It is rare that a query can be fulfilled in a single request to the server. There are two ways a query can be incomplete. All queries return a list of pages as their result. The result may be incomplete because not all the data for each page has been returned. In this case the batch is incomplete. Or the data may be complete for all pages, but there are more pages available on the server. In this case the query can be continued. Thus the three functions for next_result(), next_batch() and retrieve_all().

Examples

Run this code
# Try out a request using next_result(), then retrieve the rest of the
# results. The clllimt limits the first request to 40 results.
preview <- wiki_action_request() %>%
  query_by_title("Steve Wozniak") %>%
  query_page_properties("categories", cllimit = 40) %>%
  next_result()
preview

all_results <- retrieve_all(preview)
all_results

# tidyr is useful for list-columns.
all_results %>%
  tidyr::unnest(cols=c(categories), names_sep = "_")

Run the code above in your browser using DataLab