Skip to main content

Utility for parsing the OpenGraph tags - with customizable User-Agent headers

Project description


utility for parsing the Open Graph tags from url

(read more about the specification at


   $ pip install opengrapher


   >>> import opengrapher
   >>> opengrapher.parse('')
      "url": "",
      "title": "Pulp Fiction (1994) - IMDb",
      "type": "",
      "image": ",0,630,1200_AL_.jpg",
      "description": """
         Directed by Quentin Tarantino.  With John Travolta, Uma Thurman,
         Samuel L. Jackson, Bruce Willis. The lives of two mob hitmen,
         a boxer, a gangster and his wife, and a pair of diner bandits
         intertwine in four tales of violence and redemption.

List of parsing tags is stored in PARSE_TAGS constant

   >>> from opengrapher import PARSE_TAGS
   ["url", "title", "type", "image", "description"]

You can pass a specific list of tags to parse function if you want:

   >>> import opengrapher
   >>> custom_tags = ['url', 'title']
   >>> opengrapher.parse('', parse_tags=custom_tags)
      "url": "",
      "title": "Pulp Fiction (1994) - IMDb",

You can also pass a custom user-agent header to be used when fetching the url, in the event that the site blocks generic python-requests user-agent strings:

>>> import opengrapher
>>> user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246"
>>> opengrapher.parse('', user_agent=user_agent)
   "url": "",
   "title": "Pulp Fiction (1994) - IMDb",

Note that all tags will be transformed to "og:{tag}" format, as it stated in opengraph notation

Project details

Download files

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

Source Distributions

No source distribution files available for this release. See tutorial on generating distribution archives.

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page