#extract #graph #open #protocols #markup #parses #html

opengraph

Parses html and extracts Open Graph protocol markup

11 releases

Uses old Rust 2015

0.2.4 Oct 5, 2018
0.2.3 Mar 6, 2018
0.1.5 Jun 23, 2017
0.1.3 May 9, 2017
0.1.2 Apr 30, 2017

#198 in Video

Download history 8/week @ 2024-01-01 1/week @ 2024-01-29 112/week @ 2024-02-05 7/week @ 2024-02-12 12/week @ 2024-02-19 81/week @ 2024-02-26 17/week @ 2024-03-04 40/week @ 2024-03-11 85/week @ 2024-03-18 27/week @ 2024-03-25

173 downloads per month

MIT license

16KB
447 lines

opengraph

opengraph is a library that parses html and extracts Open Graph protocol markup.

Usage

  • Add opengraph to dependencies in Cargo.toml
[dependencies]
opengraph = "^0"
  • Then, use opengraph::scrape as below:

extern crate opengraph;

fn main() {
  match opengraph::scrape("https://spincoaster.com/chromeo-juice", Default::default()) {
      Ok(object) => {
          println!("{:?}", object);
      },
      Err(_) => println!("error occured"),
  }
}

or use opengraph::extract as below:

extern crate opengraph;

fn main() {
    let x = r#"
<html prefix="og: http://ogp.me/ns#">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
</head>
</html>
             "#;
    match opengraph::extract(&mut x.to_string().as_bytes(), Default::default()) {
        Ok(object) => {
            println!("{:?}", object);
        },
        Err(_) => println!("error occured"),
    }
}

License

MIT

Dependencies

~20MB
~448K SLoC