Skip to main content

Library to find URLs and check their validity.

Project description

urlfinderlib

This is a Python (3.6+) library for finding URLs in documents and checking their validity.

Supported Documents

Extracts URLs from the following types of documents:

  • Binary files (finds URLs within strings)
  • CSV files
  • HTML files
  • iCalendar/vCalendar files
  • PDF files
  • Text files (ASCII or UTF-8)
  • XML files

Every extracted URL is validated such that it contains a domain with a valid TLD (or a valid IP address) and does not contain any invalid characters.

URL Permutations

This was originally written to accommodate finding both valid and obfuscated or slightly malformed URLs used by malicious actors and using them as indicators of compromise (IOCs). As such, the extracted URLs will also include the following permutations:

  • URL with any Unicode characters in its domain
  • URL with any Unicode characters converted to its IDNA equivalent

For both domain variations, the following permutations are also returned:

  • URL with its path %-encoded
  • URL with its path %-decoded
  • URL with encoded HTML entities in its path
  • URL with decoded HTML entities in its path
  • URL with its path %-decoded and HTML entities decoded

Child URLs

This library also attempts to extract or decode child URLs found in the paths of URLs. The following formats are supported:

  • Barracuda protected URLs
  • Base64-encoded URLs found within the URL's path
  • Google redirect URLs
  • Mandrill/Mailchimp redirect URLs
  • Outlook Safe Links URLs
  • Proofpoint protected URLs
  • URLs found in the URL's path query parameters

Basic usage

from urlfinderlib import find_urls

with open('/path/to/file', 'rb') as f:
    print(find_urls(f.read())

base_url Parameter

If you are trying to find URLs inside of an HTML file, the paths in the URLs are often relative to their location on the server hosting the HTML. You can use the base_url parameter in this case to extract these "relative" URLs.

from urlfinderlib import find_urls

with open('/path/to/file', 'rb') as f:
    print(find_urls(f.read(), base_url='http://example.com')

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

urlfinderlib-0.18.5.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

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

urlfinderlib-0.18.5-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file urlfinderlib-0.18.5.tar.gz.

File metadata

  • Download URL: urlfinderlib-0.18.5.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for urlfinderlib-0.18.5.tar.gz
Algorithm Hash digest
SHA256 6a6467c89187f4cc97856668bd43d88a5a92c28e705fb832bf78b7e42b586bcf
MD5 58b756f4e4f753747930b79557d2fef6
BLAKE2b-256 7e136300247cd8b382860d8bb28519bce5d98156e3c2b0bf8b7e1ca8be4f9adc

See more details on using hashes here.

File details

Details for the file urlfinderlib-0.18.5-py3-none-any.whl.

File metadata

  • Download URL: urlfinderlib-0.18.5-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for urlfinderlib-0.18.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d77750ec128b47db961196a65057852f94a9d83289abee0b97ee28dfe5e32762
MD5 5ca8f2635391cd6b173e13de7f7f0255
BLAKE2b-256 3d6ea7374ac9883ecd7cec6eaf0b5969f7f74d4080210452f82df453bb3fbb88

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page