opengraph_py3


Nameopengraph_py3 JSON
Version 0.71 PyPI version JSON
download
home_pagehttps://github.com/erikriver/opengraph
SummaryA module to parse the Open Graph Protocol. Ported to Python3.6 using 2to3-3.6
upload_time2018-02-27 11:52:58
maintainer
docs_urlNone
authorErik Rivera
requires_python
licenseMIT
keywords opengraph protocol facebook
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            OpenGraph is a module of python for parsing the Open Graph Protocol, you can read more about the specification at http://ogp.me/

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

Installation
=============

.. code-block:: console

   $ pip install opengraph-py3.6

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**

.. code-block:: pycon

   >>> 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**

.. code-block:: pycon

   >>> 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**

.. code-block:: pycon

   >>> 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." />


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/erikriver/opengraph",
    "name": "opengraph_py3",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "opengraph protocol facebook",
    "author": "Erik Rivera",
    "author_email": "erik.river@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/28/a5/b3c3c9f07251fdf2370593bc5a79c71715b46cdf528adb54dc38014cd95b/opengraph_py3-0.71.tar.gz",
    "platform": "",
    "description": "OpenGraph is a module of python for parsing the Open Graph Protocol, you can read more about the specification at http://ogp.me/\n\nNote : This repository has only porting related changes and was basically created to make these changes available on PyPi.\n\nInstallation\n=============\n\n.. code-block:: console\n\n   $ pip install opengraph-py3.6\n\nFeatures\n=============\n\n* Use it as a python dict\n* Input and parsing from a specific url\n* Input and parsung from html previous extracted\n* HTML output\n* JSON output\n\nUsage\n==============\n\n**From an URL**\n\n.. code-block:: pycon\n\n   >>> import opengraph\n   >>> video = opengraph.OpenGraph(url=\"http://www.youtube.com/watch?v=q3ixBmDzylQ\")\n   >>> video.is_valid()\n   True\n   >>> for x,y in video.items():\n   ...     print \"%-15s => %s\" % (x, y)\n   ...\n   site_name       => YouTube\n   description     => Eric Clapton and Paul McCartney perform George Harrison's \"While My Guitar Gently Weeps\" at the...\n   title           => While My Guitar Gently Weeps\n   url             => http://www.youtube.com/watch?v=q3ixBmDzylQ\n   image           => http://i2.ytimg.com/vi/q3ixBmDzylQ/default.jpg\n   video:type      => application/x-shockwave-flash\n   video:height    => 224\n   video           => http://www.youtube.com/v/q3ixBmDzylQ?version=3&autohide=1\n   video:width     => 398\n   type            => video\n\n**From HTML**\n\n.. code-block:: pycon\n\n   >>> HTML = \"\"\"\n   ... <html xmlns:og=\"http://ogp.me/ns#\">\n   ... <head>\n   ... <title>The Rock (1996)</title>\n   ... <meta property=\"og:title\" content=\"The Rock\" />\n   ... <meta property=\"og:type\" content=\"movie\" />\n   ... <meta property=\"og:url\" content=\"http://www.imdb.com/title/tt0117500/\" />\n   ... <meta property=\"og:image\" content=\"http://ia.media-imdb.com/images/rock.jpg\" />\n   ... </head>\n   ... </html>\n   ... \"\"\"\n   >>> movie = opengraph.OpenGraph() # or you can instantiate as follows: opengraph.OpenGraph(html=HTML)\n   >>> movie.parser(HTML)\n   >>> video.is_valid()\n   True\n\n**Generate JSON or HTML**\n\n.. code-block:: pycon\n\n   >>> ogp = opengraph.OpenGraph(\"http://ogp.me/\")\n   >>> print ogp.to_json()\n   {\"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.\"}\n   >>> print ogp.to_html()\n\n   <meta property=\"og:image:type\" content=\"image/png\" />\n   <meta property=\"og:title\" content=\"Open Graph protocol\" />\n   <meta property=\"og:url\" content=\"http://ogp.me/\" />\n   <meta property=\"og:image\" content=\"http://ogp.me/logo.png\" />\n   <meta property=\"og:scrape\" content=\"False\" />\n   <meta property=\"og:_url\" content=\"http://ogp.me/\" />\n   <meta property=\"og:image:height\" content=\"300\" />\n   <meta property=\"og:type\" content=\"website\" />\n   <meta property=\"og:image:width\" content=\"300\" />\n   <meta property=\"og:description\" content=\"The Open Graph protocol enables any web page to become a rich object in a social graph.\" />\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A module to parse the Open Graph Protocol. Ported to Python3.6 using 2to3-3.6",
    "version": "0.71",
    "project_urls": {
        "Homepage": "https://github.com/erikriver/opengraph"
    },
    "split_keywords": [
        "opengraph",
        "protocol",
        "facebook"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28a5b3c3c9f07251fdf2370593bc5a79c71715b46cdf528adb54dc38014cd95b",
                "md5": "2f9f1da4c11dbf3f13bf3c4e91660f34",
                "sha256": "4ae982cc02fceda9b47fa3e4e860aebc387210bc153c7328e76a1c85ccc94d1c"
            },
            "downloads": -1,
            "filename": "opengraph_py3-0.71.tar.gz",
            "has_sig": false,
            "md5_digest": "2f9f1da4c11dbf3f13bf3c4e91660f34",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4282,
            "upload_time": "2018-02-27T11:52:58",
            "upload_time_iso_8601": "2018-02-27T11:52:58.062161Z",
            "url": "https://files.pythonhosted.org/packages/28/a5/b3c3c9f07251fdf2370593bc5a79c71715b46cdf528adb54dc38014cd95b/opengraph_py3-0.71.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2018-02-27 11:52:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "erikriver",
    "github_project": "opengraph",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "opengraph_py3"
}
        
Elapsed time: 0.07229s