socialpeek

AuthorMiguel Molina <miguel@erizocosmi.co>
LicenseMIT
Homepagehttps://github.com/erizocosmico/ocaml-socialpeek
Issue Trackerhttps://github.com/erizocosmico/ocaml-socialpeek/issues
MaintainerMiguel Molina <miguel@erizocosmi.co>
Dependencies
&base
cohttp-lwt-unix0.100.0
jbuilder>= 1.0+beta10
lambdasoup0.7.0
lwt_ssl1.2.0
ounit>= 2.0.6
Availableocaml-version >= "4.02.3"
PublishedJan 10, 2018
Source [http] https://github.com/erizocosmico/ocaml-socialpeek/archive/1.0.0.tar.gz
a0af71f8d0761d948d29052b68cf850b
StatisticsInstalled 5 times last month.
Edithttps://github.com/ocaml/opam-repository/tree/master/packages/socialpeek/socialpeek.1.0.0/opam

OCaml library to extract social information such as Twitter cards or OpenGraph data from webpages and HTML.

Usage

Get twitter card

open Socialpeek

let () =
  (** you can use `from_html` instead if you already have the HTML *)
  let twitter_card = from_url "http://something.cool" |> Twitter.get_card in
  match twitter_card with
  | Twitter.Summary data -> (** Do something with data *)
  | Twitter.Summary_large_image data -> (** Do something with data *)
  | Twitter.App data -> (** Do something with data *)
  | Twitter.Player data -> (** Do something with data *)

Twitter cards can have 4 different shapes: summary, summary_large_image, app or player (more info about twitter cards). So the result of Twitter.get_card is a variant type that holds only the data a certain type of card can have.

Get Opengraph data

open Socialpeek

let () =
  (** you can use `from_html` instead if you already have the HTML *)
  let og_data = from_url "http://something.cool" |> Opengraph.get_data in
  (** do something with the data *)

Get twitter and opengraph data

open Socialpeek

let () =
  (** you can use `from_html` instead if you already have the HTML *)
  let tags = from_url "http://something.cool" in
  let og_data = Opengraph.get_data tags in
  let twitter_card = Twitter.get_card tags in
  (** do something with the data *)
No package is dependent