Skip to main content

Tweesky

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

How to use it

Install the module: PyPi Tweesky page

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

Metadata

Release files for tweesky 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tweesky 0.0.6
File Size Uploaded
tweesky-0.0.6.tar.gz 16.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tweesky 0.0.6
File Interpreter ABI Platform
tweesky-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 34.2 kB

Release files / tweesky-0.0.6.tar.gz

Download URL tweesky-0.0.6.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
88d8cca30657cfe1ee2abd5525968ef314214a09d36be9f763a54282f3b1863b
BLAKE2b-256 checksum
How to use checksums
55aa82fd780850e94c6d711ea55ac2fd1f3200fa99b2e6573838603dc6fc5c7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2

Release files / tweesky-0.0.6-py3-none-any.whl

Download URL tweesky-0.0.6-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b99bbfabcd6a46c1abeb44017c897285c7b0a8fc5bc91dac44f79db61b45d57d
BLAKE2b-256 checksum
How to use checksums
e12d4dfd3579adb976dd370394828ffd7b14693822ec48819a1e6d357cd19138
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page