All Projects → lipoja → Urlextract

lipoja / Urlextract

Licence: mit
URLExtract is python class for collecting (extracting) URLs from given text based on locating TLD.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Urlextract

Getjs
A tool to fastly get all javascript sources/files
Stars: ✭ 190 (+37.68%)
Mutual labels:  hacktoberfest, extract
Archiver
Easily create & extract archives, and compress & decompress files of various formats
Stars: ✭ 3,373 (+2344.2%)
Mutual labels:  hacktoberfest, extract
Leasot
Parse and output TODOs and FIXMEs from comments in your files
Stars: ✭ 729 (+428.26%)
Mutual labels:  hacktoberfest, extract
Tallyassist
Open source Flutter-based template for a business assistant application
Stars: ✭ 137 (-0.72%)
Mutual labels:  hacktoberfest
Reduxmoviedb
🎥 See the upcoming movies! ReSwift + RxSwift 💖 Hacktoberfest 🎃
Stars: ✭ 137 (-0.72%)
Mutual labels:  hacktoberfest
Plugin Installation Manager Tool
Plugin Manager CLI tool for Jenkins
Stars: ✭ 138 (+0%)
Mutual labels:  hacktoberfest
Odoo Brasil
Versão 14 - Odoo Brasil
Stars: ✭ 137 (-0.72%)
Mutual labels:  hacktoberfest
Slatwall
Slatwall - An Open Source Commerce Platform
Stars: ✭ 136 (-1.45%)
Mutual labels:  hacktoberfest
Rf24
OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices
Stars: ✭ 1,813 (+1213.77%)
Mutual labels:  hacktoberfest
Homebrew
Development repository for the homebrew cookbook
Stars: ✭ 137 (-0.72%)
Mutual labels:  hacktoberfest
Bandcamp Scraper
A scraper for https://bandcamp.com
Stars: ✭ 137 (-0.72%)
Mutual labels:  hacktoberfest
Irremoteesp8266
Infrared remote library for ESP8266/ESP32: send and receive infrared signals with multiple protocols. Based on: https://github.com/shirriff/Arduino-IRremote/
Stars: ✭ 1,964 (+1323.19%)
Mutual labels:  hacktoberfest
Superview
A small program that takes a 4:3 aspect ratio video file, and transforms it to a 16:9 video using the GoPro SuperView method
Stars: ✭ 137 (-0.72%)
Mutual labels:  hacktoberfest
Layer5
Layer5, the service mesh company, representing every service mesh
Stars: ✭ 137 (-0.72%)
Mutual labels:  hacktoberfest
Styleguide
The VTEX Design System and React component library.
Stars: ✭ 138 (+0%)
Mutual labels:  hacktoberfest
Covid19stats
A simple mobile app developed with Flutter to visualize Covid19 statistics 🦠
Stars: ✭ 136 (-1.45%)
Mutual labels:  hacktoberfest
Specflow
#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
Stars: ✭ 1,827 (+1223.91%)
Mutual labels:  hacktoberfest
Create robot
ROS driver for iRobot Create 1 and 2.
Stars: ✭ 137 (-0.72%)
Mutual labels:  hacktoberfest
Strimzi Kafka Bridge
Apache Kafka bridge
Stars: ✭ 137 (-0.72%)
Mutual labels:  hacktoberfest
Simple Dialer
A handy phone call manager with phonebook, number blocking and multi-SIM support
Stars: ✭ 138 (+0%)
Mutual labels:  hacktoberfest

URLExtract

URLExtract is python class for collecting (extracting) URLs from given text based on locating TLD.

.. image:: https://img.shields.io/travis/lipoja/URLExtract/master.svg :target: https://travis-ci.org/lipoja/URLExtract :alt: Build Status .. image:: https://img.shields.io/github/tag/lipoja/URLExtract.svg :target: https://github.com/lipoja/URLExtract/tags :alt: Git tag .. image:: https://img.shields.io/pypi/pyversions/urlextract.svg :target: https://pypi.python.org/pypi/urlextract :alt: Python Version Compatibility

How does it work


It tries to find any occurrence of TLD in given text. If TLD is found it
starts from that position to expand boundaries to both sides searching
for "stop character" (usually whitespace, comma, single or double
quote).

A dns check option is available to also reject invalid domain names.

NOTE: List of TLDs is downloaded from iana.org to keep you up to date with new TLDs.

Installation
~~~~~~~~~~~~

Package is available on PyPI - you can install it via pip.

.. image:: https://img.shields.io/pypi/v/urlextract.svg
    :target: https://pypi.python.org/pypi/urlextract
.. image:: https://img.shields.io/pypi/status/urlextract.svg
    :target: https://pypi.python.org/pypi/urlextract

::

   pip install urlextract

Documentation
~~~~~~~~~~~~~

Online documentation is published at http://urlextract.readthedocs.io/


Requirements
~~~~~~~~~~~~

- IDNA for converting links to IDNA format
- uritools for domain name validation
- appdirs for determining user's cache directory
- dnspython to cache DNS results

   ::

       pip install idna
       pip install uritools
       pip install appdirs
       pip install dnspython

Example
~~~~~~~

You can look at command line program at the end of *urlextract.py*.
But everything you need to know is this:

.. code:: python

    from urlextract import URLExtract

    extractor = URLExtract()
    urls = extractor.find_urls("Text with URLs. Let's have URL janlipovsky.cz as an example.")
    print(urls) # prints: ['janlipovsky.cz']

Or you can get generator over URLs in text by:

.. code:: python

    from urlextract import URLExtract

    extractor = URLExtract()
    example_text = "Text with URLs. Let's have URL janlipovsky.cz as an example."

    for url in extractor.gen_urls(example_text):
        print(url) # prints: ['janlipovsky.cz']

Or if you want to just check if there is at least one URL you can do:

.. code:: python

    from urlextract import URLExtract

    extractor = URLExtract()
    example_text = "Text with URLs. Let's have URL janlipovsky.cz as an example."

    if extractor.has_urls(example_text):
        print("Given text contains some URL")

If you want to have up to date list of TLDs you can use ``update()``:

.. code:: python

    from urlextract import URLExtract

    extractor = URLExtract()
    extractor.update()

or ``update_when_older()`` method:

.. code:: python

    from urlextract import URLExtract

    extractor = URLExtract()
    extractor.update_when_older(7) # updates when list is older that 7 days

Known issues
~~~~~~~~~~~~

Since TLD can be not only shortcut but also some meaningful word we might see "false matches" when we are searching
for URL in some HTML pages. The false match can occur for example in css or JS when you are referring to HTML item
using its classes.

Example HTML code:

.. code-block:: html

  <p class="bold name">Jan</p>
  <style>
    p.bold.name {
      font-weight: bold;
    }
  </style>

If this HTML snippet is on the input of ``urlextract.find_urls()`` it will return ``p.bold.name`` as an URL.
Behavior of urlextract is correct, because ``.name`` is valid TLD and urlextract just see that there is ``bold.name``
valid domain name and ``p`` is valid sub-domain.

License
~~~~~~~

This piece of code is licensed under The MIT License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].