Metadata-Version: 2.1
Name: linkpreview
Version: 0.6.5
Summary: Get link (URL) preview
Home-page: UNKNOWN
Author: MeyT
License: MIT
Description: # linkpreview
        
        [![Build Status](https://github.com/meyt/linkpreview/actions/workflows/main.yaml/badge.svg)](https://github.com/meyt/linkpreview/actions)
        [![Coverage Status](https://coveralls.io/repos/github/meyt/linkpreview/badge.svg?branch=master)](https://coveralls.io/github/meyt/linkpreview?branch=master)
        [![pypi](https://img.shields.io/pypi/pyversions/linkpreview.svg)](https://pypi.python.org/pypi/linkpreview)
        
        Get link preview in python
        
        Gathering data from:
        
        1. [OpenGraph](https://ogp.me/) meta tags
        2. [TwitterCard](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/abouts-cards) meta tags
        3. [Microdata](https://en.wikipedia.org/wiki/Microdata_(HTML)) meta tags
        4. [JSON-LD](https://en.wikipedia.org/wiki/JSON-LD) meta tags
        5. HTML Generic tags (`h1`, `p`, `img`)
        6. URL readable parts
        
        ## Install
        
        ```
        pip install linkpreview
        ```
        
        ## Usage
        
        ### Basic
        
        ```python
        from linkpreview import link_preview
        
        url = "http://localhost"
        content = """
        <!DOCTYPE html>
        <html>
          <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width">
            <!-- ... --->
            <title>a title</title>
          </head>
          <body>
          <!-- ... --->
          </body>
        </html>
        """
        preview = link_preview(url, content)
        print("title:", preview.title)
        print("description:", preview.description)
        print("image:", preview.image)
        print("force_title:", preview.force_title)
        print("absolute_image:", preview.absolute_image)
        print("site_name:", preview.site_name)
        ```
        
        ### Automatic fetch link content
        
        ```python
        from linkpreview import link_preview
        
        preview = link_preview("http://github.com/")
        print("title:", preview.title)
        print("description:", preview.description)
        print("image:", preview.image)
        print("force_title:", preview.force_title)
        print("absolute_image:", preview.absolute_image)
        print("site_name:", preview.site_name)
        ```
        
        ### `lxml` as XML parser
        
        Very recommended for better performance.
        
        [Install](https://lxml.de/installation.html) the `lxml` and use it like this:
        
        ```python
        from linkpreview import link_preview
        
        preview = link_preview("http://github.com/", parser="lxml")
        print("title:", preview.title)
        print("description:", preview.description)
        print("image:", preview.image)
        print("force_title:", preview.force_title)
        print("absolute_image:", preview.absolute_image)
        print("site_name:", preview.site_name)
        ```
        
        ### Advanced
        
        ```python
        from linkpreview import Link, LinkPreview, LinkGrabber
        
        url = "http://github.com"
        grabber = LinkGrabber(
            initial_timeout=20,
            maxsize=1048576,
            receive_timeout=10,
            chunk_size=1024,
        )
        content, url = grabber.get_content(url)
        link = Link(url, content)
        preview = LinkPreview(link, parser="lxml")
        print("title:", preview.title)
        print("description:", preview.description)
        print("image:", preview.image)
        print("force_title:", preview.force_title)
        print("absolute_image:", preview.absolute_image)
        print("site_name:", preview.site_name)
        ```
        
Keywords: link preview web htmlparse schema.org opengraph twittercard url
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Software Development :: Libraries
Description-Content-Type: text/markdown
