Learn R Programming

WikipediaR (version 1.1)

links: lists links on a Wikipedia page

Description

lists all links (to wikipedia and to external url) that are present in a specific wikipedia page.

Usage

links(page = NULL, domain = "en")

Arguments

page
numeric identifier or character title of the specific wikipedia page
domain
a character value specifying the language of the wikipedia url.The default value is "en" for "english language".

Value

an object of class linksClass containing:
  • call the command line
  • page title, identification number, and domain of the Wikipedia page
  • links a data frame containing title, the titles of the linked pages, ns, numbers of the namespaces (identification of the type of pages, defining nscat et nssubj, the two next variables), nscat, the categories of linked pages (Subject, Talk, or Virtual), nssubj, the subjects of the linked pages (Main Article, User, Wikipedia, File, MediaWiki, Template, Help, Category, Protal, Book, Draft, Education Program, TimedText, Module, Topic, Special, Media, Other). For more details about namespace, see http://www.mediawiki.org/wiki/Help:Namespaces and http://en.wikipedia.org/wiki/Wikipedia:Namespace#Subject_namespaces
  • extlinks a vector containing the list of url of external links. If there is no external link in the page, this item is not created.
  • testWikiPagea list of four elements,
    • takeOnlyFirst a boolean indicating if the class of page parameter is invalid, for example vector, list, matrix..., and in that case, only the first element is considered.
    • redirPage title of the redirected url. This item is NULL if the page is not redirected.
    • test an integer with value:
      • 4 for invalid domain,
      • 3 for an empty parameter page,
      • 2 when Wikipedia does not have an article with this exact name,
      • 1 for ambiguous page, direct or redirect,
      • 0 for valid an unambiguous page, direct or redirect.
    • warnMessage is a vector of warning messages.

Details

This function uses the MediaWiki API query syntax: "prop=links". For more details, see http://www.mediawiki.org/wiki/API:Properties#links_.2F_pl.

See Also

print.linksClass backLinks

Examples

Run this code
## Not run: 
# # a simple example
# links("Louis Pasteur") # default domain : en
# 
# # with a redirected page
# links.Obama <- links(page ="Obama")
# links.Obama
# # warning message
# 
# # a simple example with page specified by its page ID number
# links(page = 976, domain = "fr" )
# 
# # with a page that not exist (at the moment of the redaction of this help page)
# links("zzzzz") 
# ## End(Not run)

Run the code above in your browser using DataLab