Same fetch-then-read pipeline as
the web-data vignette, but starting from a topic rather than a known set
of publishers. fetch_wiki_urls() finds Wikipedia article
URLs; fetch_wiki_refs() follows each article’s References
section to collect cited external URLs – primary sources, reports, and
news. read_urls() handles both kinds of URL in the same
way.
Start from a topic.
fetch_wiki_urls(query, limit) returns Wikipedia article
URLs matching a search phrase. Use that as your seed set.
#> [1] "https://en.wikipedia.org/wiki/January_6_United_States_Capitol_attack"
#> [2] "https://en.wikipedia.org/wiki/Pardon_of_January_6_United_States_Capitol_attack_defendants"
#> [3] "https://en.wikipedia.org/wiki/Timeline_of_the_January_6_United_States_Capitol_attack"
#> [4] "https://en.wikipedia.org/wiki/Criminal_proceedings_in_the_January_6_United_States_Capitol_attack"
#> [5] "https://en.wikipedia.org/wiki/Aftermath_of_the_January_6_United_States_Capitol_attack"
Follow References. Articles cite external sources;
those URLs are often high-value (primary sources, reports, news).
fetch_wiki_refs(url, n) returns one flat
data.table with source_url (the Wikipedia
page) and ref_url (the cited link), whether
url contains one Wikipedia page or several. Use
n to cap references per page.
So: wiki article URLs + URLs from their References sections = an expanded URL list. You can then read both the articles and the cited pages.
Character vector of URLs → data frame (one row per node: headings,
paragraphs, lists). Use read_urls() on any of the URLs you
collected above.
Wikipedia has special status in
read_urls(). When the URL is a Wikipedia page, the
function uses Wikipedia’s main-content selector
(div.mw-parser-output) and preserves section structure via
parent_heading. Boilerplate detection is off for Wikipedia.
exclude_wiki_refs = TRUE (default) drops
nodes under References, See also, Bibliography, and Sources so you get
article body only; set to FALSE to include those
sections.
fetch_wiki_urls() and fetch_wiki_refs()
extend the same fetch-then-read pipeline to Wikipedia – useful when you
want a topic-seeded corpus that includes both article text and cited
primary sources. read_urls() handles the result identically
to any other URL list, returning $text and
$meta.