Process Metadata from the 'Open Graph Protocol'

Social media sites often embed cards when links are shared, based on metadata in the 'Open Graph Protocol' (< https://ogp.me/>). This supports extracting that metadata from a website. It further allows for the creation of tags to add to a website to support the 'Open Graph Protocol' and provides a list of the standard tags and their required properties.


opengraph

CRANstatus opengraph statusbadge Lifecycle:stable R-CMD-check Codecov testcoverage

The goal of opengraph is to read and process Open Graph Protocol metadata on websites.

Installation

You can install the development version of opengraph from GitHub with:

# install.packages('pak')
pak::pak('christopherkenny/opengraph')

Example

This is a relatively simple package. The main function is og_parse() which returns a named vector of Open Graph metadata found on a given webpage.

library(opengraph)
url <- 'https://christophertkenny.com/opengraph/'
og_parse(url)
#>                                                           title 
#>                               "Process the Open Graph Protocol" 
#>                                                     description 
#> "Parse metadata on websites which use the Open Graph Protocol." 
#>                                                           image 
#>               "http://christophertkenny.com/opengraph/logo.png"

The package can also read specific Open Graph properties with og_property(). Properties can be prefixed with og: or not.

og_property(url, 'og:title')
#> [1] "Process the Open Graph Protocol"
og_property(url, 'title')
#> [1] "Process the Open Graph Protocol"

If there is no Open Graph metadata found, og_parse() will return an empty named vector.

og_parse('https://cran.r-project.org/')
#> named character(0)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("opengraph")

0.0.4 by Christopher T. Kenny, a year ago


https://github.com/christopherkenny/opengraph, https://christophertkenny.com/opengraph/


Browse source code at https://github.com/cran/opengraph


Authors: Christopher T. Kenny [aut, cre] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports rvest

Suggests spelling, testthat


Imported by bskyr.


See at CRAN