guardian_content: Search Guardian Content

Description Usage Arguments See Also Examples

View source: R/content.R

Description

guardian_content lets you directly search The Guardian for content, including support for conditional searches, date-range based filtering, and section or tag based filtering.

Usage

1
2
3
4
guardian_content(api_key, query, from = NULL, to = NULL, section = NULL,
  reference = NULL, reference_type = NULL, tags = NULL, rights = NULL,
  ids = NULL, production_office = NULL, page = NULL, page_size = 50,
  fields = NULL, collapse = TRUE, ...)

Arguments

api_key

A key to the Guardian API, which can be obtained here.

query

Your search query. This can contain operators (sausage AND mash) or phrases ("sausage & mash"); by default, searches work as an OR, looking for the presence of any one individual word in the query.

from

the date to limit by. If set, the search will only cover data written after this date. Optional (NULL) by default. Can be set in conjunction with to.

to

Another date to limit by. If set, the search will only cover data written before this date. Optional (NULL) by default. Can be set in conjunction with from.

section

the section, or sections, of The Guardian that you want to limit the search to. Multiple sections may be concatenated together using boolean operators; see guardian_and and guardian_or.

reference

the references to limit the search to; only articles that include those references (and meet other conditions) will be returned. Also accepts boolean operators.

reference_type

the type of reference (such as isbn). Also accepts boolean operators.

tags

the tags to limit the search to; only articles that contain these tags will be returned. Also accepts boolean operators.

rights

limit a search to content with these rights (syndicatable content, for example). Options are syndicatable and subscription-database. Does not accept boolean operators.

ids

limit a search to content with these IDs, an ID being the standard URL fragment after guardian.com ( or co.uk, or...). Does not accept boolean operators.

production_office

the production office(s) to limit to, such as "aus". Accepts boolean operators.

page

a particular page of results to return. Useful when returning multiple sets of data with the same query; you can repeat the query, incrementing the value in page.

page_size

the maximum number of items to return; anywhere between 1 and 50. Set to 50 by default.

fields

additional fields to include in the returned data (when available). Possible values (which should appear in a vector) appear here.

collapse

whether to collapse the actual content into a data.frame. Set to TRUE by default.

...

further arguments to pass to httr's GET.

See Also

guardian_tags to retrieve metadata about tags.

Examples

1
2
3
4
5
# Simple example
## Not run: 
result <- guardian_content("test", "debate AND economy")

## End(Not run)

rdian documentation built on May 2, 2019, 3:26 p.m.