tweesky


Nametweesky JSON
Version 0.0.6 PyPI version JSON
download
home_pagehttps://github.com/gcatanese/Tweesky
SummaryGrab OpenGraph and Twitter Cards metadata from URLs, HTML documents and Spotify links
upload_time2023-01-04 12:10:27
maintainer
docs_urlNone
authorBeppe Catanese
requires_python
licenseApache-2.0
keywords opengraph twittercards social media spotify
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Tweesky

Tweesky is a Python library for extracting **HTML**, **OpenGraph** and **Twitter** metadata from URLs, HTML pages and 
Spotify links.

* Check [Tweesky Web Site](https://tweesky.online/): example of what Tweesky can do
* Read [Intro on Medium](https://medium.com/@beppe.catanese/tweesky-dont-miss-the-twitter-card-preview-19c95f3417d9) 

## How to use it

Install the module: [PyPi Tweesky page](https://pypi.org/project/tweesky/)

Grab attributes from a URL
```
    import tweesky.main as tweesky
    
    website = 'https://www.nike.com/'
    card = tweesky.generate_card(url=website)
    
    print(card.title)
    print(card.image)
```

Grab attributes from an HTML document
```
    import tweesky.main as tweesky

    with open('doc.html', 'r') as reader:
        doc = reader.readlines()
    card = tweesky.generate_card(html=doc)
    
    print(card.title)
    print(card.image)
```

## Output options

There are different options to format the card:
* Card object (default): access the Python object to obtain the metadata
* JSON output: the Card content is provided as JSON
* HTML file: an HTML file is provided including the metadata necessary for creating the Social Media preview

### HTML format

When using `main.generate_card_as_html()` method the output is an HTML document which can be shared **as-is** on Social Media.

The HTML document provides all necessary OpenGraph/Twitter tags as well as the Javascript code to redirect the users to
the original page: save the file on an accessible location and distribute the link through the Social Media channels.

```
<html>
    <head>
        <meta name="twitter:card" content="summary" />
        <meta name="twitter:title" content="Python Tutorials – Real Python" />
        <meta name="twitter:description" content="Learn Python online" />
        <meta name="twitter:image" content="https://cdn.realpython.com/static/logo.png" />
        <meta name="twitter:site" content="@realpython" />
        
        <meta property="og:title" content="Python Tutorials – Real Python" />
        <meta property="og:description" content="Learn Python online" />
        <meta property="og:image" content="https://cdn.realpython.com/static/logo.png" />
        
        <meta http-equiv="refresh" content="0; url=https://realpython.com/" /> 
    </head>
    <body >
        &nbsp;
    </body>
</html>  
```


## Images

When finding the image for the Preview the library will search the following:
* Twitter Card metadata
* OpenGraph metadata
* JSON LD


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gcatanese/Tweesky",
    "name": "tweesky",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "OpenGraph,TwitterCards,Social Media,Spotify",
    "author": "Beppe Catanese",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/55/aa/82fd780850e94c6d711ea55ac2fd1f3200fa99b2e6573838603dc6fc5c7a/tweesky-0.0.6.tar.gz",
    "platform": null,
    "description": "# Tweesky\n\nTweesky is a Python library for extracting **HTML**, **OpenGraph** and **Twitter** metadata from URLs, HTML pages and \nSpotify links.\n\n* Check [Tweesky Web Site](https://tweesky.online/): example of what Tweesky can do\n* Read [Intro on Medium](https://medium.com/@beppe.catanese/tweesky-dont-miss-the-twitter-card-preview-19c95f3417d9) \n\n## How to use it\n\nInstall the module: [PyPi Tweesky page](https://pypi.org/project/tweesky/)\n\nGrab attributes from a URL\n```\n    import tweesky.main as tweesky\n    \n    website = 'https://www.nike.com/'\n    card = tweesky.generate_card(url=website)\n    \n    print(card.title)\n    print(card.image)\n```\n\nGrab attributes from an HTML document\n```\n    import tweesky.main as tweesky\n\n    with open('doc.html', 'r') as reader:\n        doc = reader.readlines()\n    card = tweesky.generate_card(html=doc)\n    \n    print(card.title)\n    print(card.image)\n```\n\n## Output options\n\nThere are different options to format the card:\n* Card object (default): access the Python object to obtain the metadata\n* JSON output: the Card content is provided as JSON\n* HTML file: an HTML file is provided including the metadata necessary for creating the Social Media preview\n\n### HTML format\n\nWhen using `main.generate_card_as_html()` method the output is an HTML document which can be shared **as-is** on Social Media.\n\nThe HTML document provides all necessary OpenGraph/Twitter tags as well as the Javascript code to redirect the users to\nthe original page: save the file on an accessible location and distribute the link through the Social Media channels.\n\n```\n<html>\n    <head>\n        <meta name=\"twitter:card\" content=\"summary\" />\n        <meta name=\"twitter:title\" content=\"Python Tutorials \u2013 Real Python\" />\n        <meta name=\"twitter:description\" content=\"Learn Python online\" />\n        <meta name=\"twitter:image\" content=\"https://cdn.realpython.com/static/logo.png\" />\n        <meta name=\"twitter:site\" content=\"@realpython\" />\n        \n        <meta property=\"og:title\" content=\"Python Tutorials \u2013 Real Python\" />\n        <meta property=\"og:description\" content=\"Learn Python online\" />\n        <meta property=\"og:image\" content=\"https://cdn.realpython.com/static/logo.png\" />\n        \n        <meta http-equiv=\"refresh\" content=\"0; url=https://realpython.com/\" /> \n    </head>\n    <body >\n        &nbsp;\n    </body>\n</html>  \n```\n\n\n## Images\n\nWhen finding the image for the Preview the library will search the following:\n* Twitter Card metadata\n* OpenGraph metadata\n* JSON LD\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Grab OpenGraph and Twitter Cards metadata from URLs, HTML documents and Spotify links",
    "version": "0.0.6",
    "split_keywords": [
        "opengraph",
        "twittercards",
        "social media",
        "spotify"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e12d4dfd3579adb976dd370394828ffd7b14693822ec48819a1e6d357cd19138",
                "md5": "babfe0310575876ce0f5292212e1e9ac",
                "sha256": "b99bbfabcd6a46c1abeb44017c897285c7b0a8fc5bc91dac44f79db61b45d57d"
            },
            "downloads": -1,
            "filename": "tweesky-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "babfe0310575876ce0f5292212e1e9ac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 18049,
            "upload_time": "2023-01-04T12:10:25",
            "upload_time_iso_8601": "2023-01-04T12:10:25.800493Z",
            "url": "https://files.pythonhosted.org/packages/e1/2d/4dfd3579adb976dd370394828ffd7b14693822ec48819a1e6d357cd19138/tweesky-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "55aa82fd780850e94c6d711ea55ac2fd1f3200fa99b2e6573838603dc6fc5c7a",
                "md5": "28aae1ca3aacf6bf6eb4e1948fb9c7c9",
                "sha256": "88d8cca30657cfe1ee2abd5525968ef314214a09d36be9f763a54282f3b1863b"
            },
            "downloads": -1,
            "filename": "tweesky-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "28aae1ca3aacf6bf6eb4e1948fb9c7c9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 16147,
            "upload_time": "2023-01-04T12:10:27",
            "upload_time_iso_8601": "2023-01-04T12:10:27.817569Z",
            "url": "https://files.pythonhosted.org/packages/55/aa/82fd780850e94c6d711ea55ac2fd1f3200fa99b2e6573838603dc6fc5c7a/tweesky-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-04 12:10:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "gcatanese",
    "github_project": "Tweesky",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "tweesky"
}
        
Elapsed time: 0.02473s