Skip to main content

A module to parse the Open Graph Protocol. Ported to Python3.6 using 2to3-3.6

Project description

OpenGraph is a module of python for parsing the Open Graph Protocol, you can read more about the specification at

Note : This repository has only porting related changes and was basically created to make these changes available on PyPi.


$ pip install opengraph-py3.6


  • Use it as a python dict
  • Input and parsing from a specific url
  • Input and parsung from html previous extracted
  • HTML output
  • JSON output


From an URL

>>> import opengraph
>>> video = opengraph.OpenGraph(url="")
>>> video.is_valid()
>>> for x,y in video.items():
...     print "%-15s => %s" % (x, y)
site_name       => YouTube
description     => Eric Clapton and Paul McCartney perform George Harrison's "While My Guitar Gently Weeps" at the...
title           => While My Guitar Gently Weeps
url             =>
image           =>
video:type      => application/x-shockwave-flash
video:height    => 224
video           =>
video:width     => 398
type            => video


>>> HTML = """
... <html xmlns:og="">
... <head>
... <title>The Rock (1996)</title>
... <meta property="og:title" content="The Rock" />
... <meta property="og:type" content="movie" />
... <meta property="og:url" content="" />
... <meta property="og:image" content="" />
... </head>
... </html>
... """
>>> movie = opengraph.OpenGraph() # or you can instantiate as follows: opengraph.OpenGraph(html=HTML)
>>> movie.parser(HTML)
>>> video.is_valid()

Generate JSON or HTML

>>> ogp = opengraph.OpenGraph("")
>>> print ogp.to_json()
{"image:type": "image/png", "title": "Open Graph protocol", "url": "", "image": "", "scrape": false, "_url": "", "image:height": "300", "type": "website", "image:width": "300", "description": "The Open Graph protocol enables any web page to become a rich object in a social graph."}
>>> print ogp.to_html()

<meta property="og:image:type" content="image/png" />
<meta property="og:title" content="Open Graph protocol" />
<meta property="og:url" content="" />
<meta property="og:image" content="" />
<meta property="og:scrape" content="False" />
<meta property="og:_url" content="" />
<meta property="og:image:height" content="300" />
<meta property="og:type" content="website" />
<meta property="og:image:width" content="300" />
<meta property="og:description" content="The Open Graph protocol enables any web page to become a rich object in a social graph." />

Project details

Release history Release notifications

This version
History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
opengraph_py3-0.71.tar.gz (4.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page