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

Download files

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

Source Distribution

tweesky-0.0.4.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tweesky-0.0.4-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file tweesky-0.0.4.tar.gz.

File metadata

  • Download URL: tweesky-0.0.4.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2

File hashes

Hashes for tweesky-0.0.4.tar.gz
Algorithm Hash digest
SHA256 00ecb78c8a62db9b8289a6d8aaf0d393d180dfe438af9c974d81e918feb7cf3f
MD5 8b37e51454cd49960f7e1f632098071e
BLAKE2b-256 38e6bfc76b93deaf660f286cd1c633d6186aa71310510a7b2580e75012d81074

See more details on using hashes here.

File details

Details for the file tweesky-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: tweesky-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2

File hashes

Hashes for tweesky-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 67b2fcb5863b8e16b0afe323405b5f07acd3b86034b5f1130acb0d8eb03558d8
MD5 d2c694f870c2d9db2d8d0826d3f1c0f5
BLAKE2b-256 70ccfbb78e3f1a20974e3ee8e587ef50a06d9a7bf1fcdbb353684dd04dbcf318

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.6

2 files

0.0.5

2 files

This release

0.0.4 This release

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 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