Topicaxis-opengraph is a fork of https://github.com/erikriver/opengraph that adds support for Python 3.
OpenGraph is a module of python for parsing the Open Graph Protocol, you can read more about the specification at http://ogp.me/
Installation
$ pip install topicaxis-opengraph
Features
Use it as a python dict
Input and parsing from a specific url
Input and parsung from html previous extracted
HTML output
JSON output
Usage
From an URL
>>> import opengraph
>>> video = opengraph.OpenGraph(url="http://www.youtube.com/watch?v=q3ixBmDzylQ")
>>> video.is_valid()
True
>>> 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 => http://www.youtube.com/watch?v=q3ixBmDzylQ
image => http://i2.ytimg.com/vi/q3ixBmDzylQ/default.jpg
video:type => application/x-shockwave-flash
video:height => 224
video => http://www.youtube.com/v/q3ixBmDzylQ?version=3&autohide=1
video:width => 398
type => video
From HTML
>>> HTML = """
... <html xmlns:og="http://ogp.me/ns#">
... <head>
... <title>The Rock (1996)</title>
... <meta property="og:title" content="The Rock" />
... <meta property="og:type" content="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>
... """
>>> movie = opengraph.OpenGraph() # or you can instantiate as follows: opengraph.OpenGraph(html=HTML)
>>> movie.parser(HTML)
>>> video.is_valid()
True
Generate JSON or HTML
>>> ogp = opengraph.OpenGraph("http://ogp.me/")
>>> print ogp.to_json()
{"image:type": "image/png", "title": "Open Graph protocol", "url": "http://ogp.me/", "image": "http://ogp.me/logo.png", "scrape": false, "_url": "http://ogp.me/", "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="http://ogp.me/" />
<meta property="og:image" content="http://ogp.me/logo.png" />
<meta property="og:scrape" content="False" />
<meta property="og:_url" content="http://ogp.me/" />
<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." />
Metadata
Release files for topicaxis-opengraph 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| topicaxis-opengraph-0.5.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| topicaxis_opengraph-0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / topicaxis-opengraph-0.5.tar.gz
| Download URL | topicaxis-opengraph-0.5.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2457fce1c3a0b2d2ce540a245fdce6d7af2d5fe67501f0cb2cf50dce388048a6
|
|
BLAKE2b-256 checksum How to use checksums |
148caff1b2d2b431264fe62e3e362a4d1ed5c1a0f5a59e2032f95941bf367294
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.5.2
|
Release files / topicaxis_opengraph-0.5-py3-none-any.whl
| Download URL | topicaxis_opengraph-0.5-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc56541b5cef8737af565980263a65699ba9dcda5a2af9cbc64db8c70c536e23
|
|
BLAKE2b-256 checksum How to use checksums |
0b731b5efbf0fb8e626e36104523d8f985acc752f310dcb623885c5c336a5893
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.5.2
|