Learn R Programming

WikidataQueryServiceR (version 0.1.1)

scrape_example: Scrape an example SPARQL query from Wikidata

Description

Scrapes SPARQL query service examples page for specified example(s). Requires rvest and urltools packages.

Usage

scrape_example(example_name, ...)

Arguments

example_name

The names of the examples as they appear on this page

...

Additional httr configurations passed to rvest

Value

The SPARQL query as a character vector.

Details

If you are planning on scraping multiple examples, please provide all the names as a single vector.

Examples

Run this code
# NOT RUN {
sparql_query <- scrape_example(c("Cats", "Horses"))
query_wikidata(sparql_query)
# returns a named list with two data frames
# one called "Cats" and one called "Horses"

sparql_query <- scrape_example("Largest cities with female mayor")
cat(sparql_query)
query_wikidata(sparql_query)
# }

Run the code above in your browser using DataLab