Sign inSign up

egg82/gov_archiver

By egg82

Updated about 1 year ago

crawls .gov domains and pushes URLs to ArchiveBox

Image
0

638

egg82/gov_archiver repository overview

📚 gov_archiver

A crawler for discovering .gov domains from the official CISA dotgov-data source and auto-submitting discovered links to an ArchiveBox instance using its REST API (requires ArchiveBox v0.8.0+).

https://github.com/egg82/archivers/tree/main/gov_archiver

✨ Description

gov_archiver fetches the latest list of .gov domains, filters out unwanted domain types (like City, County, etc.), crawls the remaining domains, respects robots.txt (optionally), parses sitemaps, and explores pages up to a specified depth. Every discovered URL is submitted to your ArchiveBox for permanent archiving.

Perfect for preserving the public record by keeping snapshots of U.S. government websites automatically.

🏗️ How it works

  • Downloads the current-full.csv domain list.
  • Filters domains by Domain type using $DOMAIN_TYPE_NEGATIVE_FILTER_REGEX.
  • For each valid domain:
    • Parses robots.txt and sitemaps if present.
    • Crawls links recursively to $DEPTH_LIMIT.
    • Filters links with built-in or custom regex rules.
    • Submits found URLs to ArchiveBox using its REST API.

🧩 Required Environment Variables

VariableDescription
ARCHIVEBOX_URLFull URL to your ArchiveBox instance (e.g., https://archive.example.com).
API_TOKENBearer token for ArchiveBox API authentication.

⚙️ Optional Environment Variables

VariableDefaultDescription
TAGgovTag to attach to all ArchiveBox submissions.
DOMAIN_TYPE_NEGATIVE_FILTER_REGEX^(City|County|State|Interstate|School|Special|Tribal)Regex for excluding certain domain types.
USER_AGENTArchiveBox Default UA stringCustom User-Agent for requests.
FOLLOW_ROBOTS1Respect robots.txt (1, true, yes = on).
REQUEST_TIMEOUT10Timeout for HTTP requests (seconds).
DEPTH_LIMIT4Maximum crawl depth.
CRAWL_DELAY0.5Delay between requests (seconds).
SIMULTANEOUS_DOMAINS3How many domains to crawl in parallel.
THREADS_PER_DOMAIN5Threads per domain crawler.
LOG_LEVELinfoOne of: debug, info, warn, error, critical.
URL_FILTERS_REGEX(built-in filters)Override default regex filters (semicolon-separated).
EXCLUDE_URLS_REGEXskips various file extensionsRegex to override default exclude URLs.
REDIS_URLnoneRedis URL, e.g. redis://:6379/0. Only required for parallel crawling or very deep (or resumable) crawls.
REDIS_USERnoneUsername for Redis authentication.
REDIS_PASSnonePassword for Redis authentication.
REDIS_NAMESPACEcrawlerNamespace/prefix for all Redis keys

✅ Example docker run

docker run \
  -e ARCHIVEBOX_URL="https://archive.example.com" \
  -e API_TOKEN="YOUR_API_TOKEN" \
  -e TAG="gov" \
  -e DEPTH_LIMIT="2" \
  egg82/gov_archiver:alpine-1.0.0

🗂️ Notes

  • Uses the official cisagov/dotgov-data CSV list to stay up to date.
  • Built-in domain type filter skips local/state/tribal domains by default — adjust with $DOMAIN_TYPE_NEGATIVE_FILTER_REGEX if needed.
  • Default filters include common static file hosts (AWS S3, Azure Blob, Google Storage, etc.) to keep related files.
  • Run on a schedule (cron, Kubernetes CronJob, etc.) to keep your ArchiveBox current.
  • Python 3.9 included by default.

Tag summary

Content type

Image

Digest

sha256:ba5e04d11

Size

28.5 MB

Last updated

about 1 year ago

docker pull egg82/gov_archiver:alpine-1.3.0