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.2.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

urlfinderlib-0.18.2-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: urlfinderlib-0.18.2.tar.gz
  • Upload date:
  • Size: 19.5 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.2.tar.gz
Algorithm Hash digest
SHA256 b071e0681cc056ec0e532f6d9185dc876dc6d62212ec1b90239e2e4d23a4caf9
MD5 929a4a6af5c225e462c36b655d0e6774
BLAKE2b-256 f76a3f0dfe0a770c9f1cf2f9ee22031d872caea4615ecd5a1c9bcb70c3ec9407

See more details on using hashes here.

File details

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

File metadata

  • Download URL: urlfinderlib-0.18.2-py3-none-any.whl
  • Upload date:
  • Size: 21.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5d83b459a362597b2c8e9967155cda2182f6e29ecd574d068417efa45fb20fd7
MD5 63743efd2ba693c27748a3322c89b5bf
BLAKE2b-256 d7a58af281cc49c2f72443dfe639158419b59f9130d01dd18271cc1971c8d224

See more details on using hashes here.

Supported by

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