Skip to main content

Minimal URL extraction / classification / HTTP check pipeline.

Project description

urlcheck-smith

PyPI version Python versions Status License Tests

A compact, fast URL analysis pipeline:

  • Extract URLs from arbitrary text files
  • Classify domains using suffix-based “site runner” rules (government, edu, private, etc.)
  • Optional HTTP checks (status, redirect, CAPTCHA/human-check heuristic)
  • Output results as CSV or JSONL
  • Standalone URL classifier (classify-url)
  • Batch classification mode (classify)
  • Supports rule presets (Japan/EU/global), custom YAML rules, explain mode, quiet mode
  • Classification: Assigns categories (e.g., government, education) based on domain suffix rules.
  • HTTP Verification: Checks reachability and captures status codes.
  • Soft 404 Detection: Identifies pages that return a 200 OK status but contain "Page Not Found" text.
  • Human-Check Detection: Flags URLs that likely lead to CAPTCHA or bot-detection screens.

Features in Detail

Soft 404 Detection

Many websites are configured to return a standard 200 OK status even when a page is missing, often displaying a custom "not found" message to users. urlcheck-smith detects this by scanning the first 2000 characters of the response for common markers like:

  • "page not found"
  • "error 404"
  • "the page you requested cannot be found"

If a marker is found, the soft_404_detected field in the output is set to True, allowing you to filter out these "ghost" pages from your results.

Installation (development)

python3 -m venv .venv
. .venv/bin/activate
pip install -e .[dev]
pytest

Commands Overview


1. scan — extract → classify → (optional) HTTP check

CSV output (default)

urlcheck-smith scan sample.txt -o urls.csv

JSONL output

urlcheck-smith scan sample.txt \
  --no-http \
  --format jsonl \
  -o urls.jsonl

Skip HTTP check

urlcheck-smith scan notes.txt --no-http -o urls_wo_status.csv

Custom rules

urlcheck-smith scan urls.txt \
  --rules my_rules.yaml \
  -o result.csv

Built-in rule presets

urlcheck-smith scan urls.txt --preset japan -o out.csv
urlcheck-smith scan urls.txt --preset eu -o out.csv
urlcheck-smith scan urls.txt --preset global -o out.csv

2. classify-url — classify a single URL

Default (JSON)

urlcheck-smith classify-url https://www.soumu.go.jp/

Explain mode

urlcheck-smith classify-url https://www.soumu.go.jp/ --explain

Output example:

{
  "url": "https://www.soumu.go.jp/",
  "base_url": "www.soumu.go.jp",
  "category": "government",
  "explain": {
    "matched_suffix": ".go.jp",
    "category": "government"
  }
}

Quiet mode (machine-friendly)

urlcheck-smith classify-url https://www.soumu.go.jp/ --quiet

Presets & custom rules

urlcheck-smith classify-url https://www.gov.uk/ --preset eu
urlcheck-smith classify-url https://policy.example.com/ --rules org_rules.yaml

3. classify — batch classify (no HTTP check)

Input file should contain one URL per line.

CSV output

urlcheck-smith classify urls.txt -o classified.csv

JSONL output

urlcheck-smith classify urls.txt --format jsonl -o out.jsonl

Quiet mode

urlcheck-smith classify urls.txt --quiet

Explain mode

urlcheck-smith classify urls.txt --explain -o out.jsonl

Rule System

Custom rule file example

suffix_rules:
  - suffix: ".go.jp"
    category: government
  - suffix: ".example.com"
    category: internal

default_category: private

Built-in presets

  • --preset japan
  • --preset eu
  • --preset global

Each corresponds to a YAML file under urlcheck_smith/data/.


Development

make install
make test

License

MIT

Project details


Download files

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

Source Distribution

urlcheck_smith-0.2.1.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

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

urlcheck_smith-0.2.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file urlcheck_smith-0.2.1.tar.gz.

File metadata

  • Download URL: urlcheck_smith-0.2.1.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for urlcheck_smith-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a8d9d165b74bbb9ad89caf2be0c37ce1933cd5cc41054450b724ee3ef340c08c
MD5 3a530037703cdeb179c3d6d8851b7d83
BLAKE2b-256 c950fd96125550b620bd4fb25375796e59ba06a5235b0ec71f17ed7eb14f7251

See more details on using hashes here.

File details

Details for the file urlcheck_smith-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: urlcheck_smith-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for urlcheck_smith-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af19385769843fa532300502059e40adb8972ba3f57caebe886079dd9a4bf5d3
MD5 59e99d97834f27c18fedd3e5bece0fe3
BLAKE2b-256 3908b02f026948d9b40ed4a0d7852feb55150cd14c239819be199ed024ce817f

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