Skip to content

About

Public keyword URL and domain scanner

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

KeywordParser

Search Bing and DuckDuckGo for public URLs, collect their domains and IP addresses, and keep the source of every result. Save each scan in its own session, resume interrupted work, and compare what changed between runs.

Python 3.10+ · Standard library only · MIT license

  • Choose Bing, DuckDuckGo, or both, with regional preferences, shared throttling, and retries.
  • Include or exclude domains and filter document extensions before applying result limits.
  • Resume saved sessions without repeating successful search pages.
  • Limit HTTP attempts or run time, then continue from the saved checkpoint.
  • Resolve original hostnames with IPv4 and optional IPv6, and export search provenance.
  • Compare sessions to find new domains, returning domains, and changes in their IP addresses.

Quick start · Usage · Sessions and resume · Output · CLI reference · Testing

Offline verification: regression tests, CLI integration tests, and dry-run

Captured from offline verification of the previous revision. The tests use mocked HTTP and DNS responses; this image is not evidence of live search coverage or the current test count. Read the captured output.

Quick start

Clone the repository and preview a small scan:

git clone https://github.com/jemtod/KeywordParser.git
cd KeywordParser

python3 dork.py "public archive" --regions ID \
  --max-results 10 --extra-pages 0 --dry-run

Remove --dry-run to run the search. The preview makes no network requests and creates no output files. A real scan needs an internet connection; no pip install step is required.

On Windows, use python if your installation does not provide python3. New sessions use English prompts, help, and progress messages. Add --lang id for Indonesian; --lang en explicitly selects English.

Usage

Choose a search engine

Both engines are enabled by default. Select one when you need to limit the scope or a provider is unavailable on your network:

python3 dork.py "public archive" --regions ID --engines bing

Use --engines bing,duckduckgo to explicitly select both. Commas and spaces are accepted as separators. Only selected engines contribute requests and checkpoints.

Keywords and files

Pass one or more keywords directly:

python3 dork.py "public archive" "service manual" --regions ID US

For a batch, create a UTF-8 text file with one keyword per line:

# keywords.txt
public archive
service manual
site:example.com filetype:pdf
python3 dork.py --file keywords.txt --regions ID

Blank lines and lines beginning with # are ignored. A UTF-8 BOM is supported, and duplicate keywords run once. You can combine direct keywords with an explicit --file.

When neither direct keywords nor --file are supplied, the script reads keyword.txt beside dork.py. Direct keywords do not automatically include that default file.

Region preferences

Use --regions ID US SG to choose regions or --regions ALL to use every available region. An interactive terminal prompts for regions when the option is omitted. New dry-runs, scripts, and other noninteractive runs require an explicit --regions.

Available region codes
ID US CA MX BR AR CL CO PE UK IE DE FR IT ES NL BE CH AT PL
SE NO DK FI PT CZ RO HU GR UA RU TR IN IL SA EG JP KR TW HK SG
MY TH VN PH AU NZ ZA AE

Regions influence search preferences. They do not restrict the country of a returned domain or IP address. Bing receives the selected country and language. DuckDuckGo receives its corresponding kl code; SA, EG, and AE use worldwide results (wt-wt).

Filter the results

Collect PDF and Word document URLs from a domain while excluding an older subdomain:

python3 dork.py "annual report" --regions ID \
  --include-domain example.com \
  --exclude-domain old.example.com \
  --extensions pdf,docx

Domain filters include the hostname itself and its subdomains. For example, example.com matches docs.example.com, but not otherexample.com. Exclusions take precedence. Repeat --include-domain or --exclude-domain for additional hostnames.

--extensions accepts comma-separated values and can also be repeated. It checks the URL path, not the file contents or query string. Rejected URLs do not consume the --max-results limit.

Control the request budget

Inspect the planned work before a larger run:

python3 dork.py --file keyword.txt --regions ID US \
  --max-results 50 --extra-pages 5 \
  --workers 4 --delay 1 --timeout 15 \
  --output scan_results --dry-run

One job is one keyword/region pair. Each query variation is sent to the selected search engines, with this many pages per engine:

pages = ceil(max_results / 10) + extra_pages

Plain phrases also get a quoted query variation. Queries with existing quotes, parentheses, colon operators such as site:, or uppercase AND/OR/NOT keep their original form. Dry-run estimates count the variations that will actually run and show an upper bound of three attempts per planned request.

Set a request budget, a duration limit, or both:

python3 dork.py --file keyword.txt --regions ID --engines bing \
  --request-budget 100 --max-duration 300

--request-budget counts actual HTTP attempts, including retries, across all workers. Cached successful pages and DNS lookups do not consume it. --max-duration sets a limit in seconds. When either limit stops the scan, the script saves its checkpoint and returns exit code 3. Requests or DNS lookups already in progress may finish within their timeout; the duration limit is not a hard process-kill deadline.

Both limits apply to the current invocation. A resume starts a fresh budget and duration window, so a small budget can process a large session in several runs. Dry-run previews work without consuming either limit.

--max-results caps unique URLs saved per job after filtering. The CLI keeps the first matching unique URLs observed for that job. All planned pages are still checked, including extra pages, even after the limit is reached. Resuming preserves previously selected URLs and keeps the same limit.

--workers limits parallel search jobs, including on large scans. Each job sends its requests sequentially. --delay is the minimum gap between request starts to the same search engine, shared by all workers and retries. Temporary errors use backoff, and Retry-After pauses the affected engine.

Progress reports completed jobs, unique URLs/domains/IPs, recorded request failures, and elapsed time. Failures remain visible when one engine succeeds and the other fails. Recognized verification or CAPTCHA pages are reported as errors.

Sessions and resume

Each new scan creates a unique folder under --output, using a UTC timestamp and a random suffix. The default parent directory is scan_results beside the script. Existing sessions and older output files are preserved.

Press Ctrl+C to stop scheduling new work and save completed results. Replace SESSION_NAME below with the session directory printed by the CLI:

python3 dork.py --resume scan_results/SESSION_NAME

Resume loads the saved keyword, region, engine, filter, and request settings. Checkpoints identify each engine/query/page combination. Successful pages are skipped, including those belonging to a partially successful job; only missing or failed pages are requested again. Failed or unfinished DNS lookups are also retried. Existing results remain in the session without duplicating identical provenance records.

To inspect the remaining work without changing the session:

python3 dork.py --resume scan_results/SESSION_NAME --dry-run

To continue with different runtime limits or language:

python3 dork.py --resume scan_results/SESSION_NAME \
  --request-budget 50 --max-duration 120 --lang en

--lang, --request-budget, and --max-duration may be overridden for a resume invocation. --dry-run and --compare are also allowed. Start a new session for different keywords, regions, engines, DNS mode, filters, workers, or result limits. The SQLite checkpoint lets the script rebuild exports after an interrupted write.

Sessions written by the previous version are upgraded when resumed. Their successful jobs remain complete; partially successful legacy jobs have no page checkpoints, so their pages run again. The upgrade preserves existing results and corrects DNS associations where the old version resolved a normalized domain instead of the original hostname. Dry-run can inspect these sessions without modifying them. Legacy sessions retain Indonesian as their saved language unless --lang en is supplied.

Compare scans

Pass the earlier session directory when starting a new scan:

python3 dork.py --file keyword.txt --regions ID \
  --compare scan_results/PREVIOUS_SESSION

The baseline may also be an older output directory containing domains.txt and, optionally, domain_ip.txt. Use the same keywords, regions, and filters for comparable coverage.

Comparison file Contents
comparison.json Domain differences, IP changes, scan statuses, and skipped IP comparisons
new_domains.txt Domains found only in the current scan
returning_domains.txt Domains present in both scans
missing_domains.txt Previous domains not found in the current scan
changed_ips.json Changed IP sets for returning domains with comparable DNS results

A missing domain is an observation about search results, not proof that the domain is offline. Search rankings and coverage can change, especially when a scan is incomplete. Failed DNS lookups are excluded from IP-change comparisons.

Output

Each session contains these files:

File Contents
urls.txt Unique URLs
domains.txt Unique domains; a leading www. is removed
hostnames.txt Unique original hostnames, including www.
ips.txt Unique IP addresses; hostname lookups use IPv4, or IPv4/IPv6 with --ipv6
hostname_ip.txt Exact hostname -> IP mappings
domain_ip.txt Normalized domain -> IP mappings, combining addresses from its hostnames
results.csv Search records for spreadsheets
results.jsonl One search record per JSON line
errors.json Search, job, and DNS failure details
summary.json Session status, counts, pending work, and duration
config.json Saved scan configuration
scan.sqlite3 Durable job, engine/query/page, result, and DNS checkpoint

The script saves page checkpoints and discovered URLs before waiting for DNS. CSV and JSONL snapshots are exported from the checkpoint, including after a controlled stop.

Both structured formats contain:

keyword, region, engine, query, url, domain, hostname, ips, found_at

found_at uses UTC. The CSV ips field uses semicolons; JSONL stores an array. A URL may have multiple records when different keywords, regions, engines, or query variations find it. The text lists remain unique.

DNS uses the original hostname, not the normalized domain. For https://www.example.com/report.pdf, the hostname is www.example.com and the normalized domain is example.com. IPs in that structured record belong to www.example.com; the apex domain may resolve differently. Domain normalization removes only the leading www., without reducing other subdomains to a registrable domain.

To request IPv6 addresses alongside IPv4:

python3 dork.py "public archive" --regions ID --ipv6

IP lists can be empty when resolution fails or is disabled. To collect URLs and domains without DNS:

python3 dork.py "public archive" --regions ID --no-dns

CLI reference

Run python3 dork.py --help for built-in help.

All command-line options
Option Default Purpose
keywords keyword.txt if no other input One or more direct keywords
-f, --file PATH None Load keywords from a text file; can combine with direct keywords
-o, --output PATH scan_results beside the script Parent directory for new session folders
--regions REGION ... Interactive selection Region codes, or ALL
--engines LIST bing,duckduckgo Search engines separated by commas or spaces
--lang en|id en for new sessions Language for CLI help, prompts, and progress
--max-results N 100 Maximum unique URLs per keyword/region after filtering
--extra-pages N 10 Extra pages per query variation and engine
--timeout SECONDS 15 Request and per-hostname DNS timeout
--delay SECONDS 0.2 Shared minimum request gap per engine
--workers N 10 Maximum parallel search jobs
--request-budget N Unlimited Maximum HTTP attempts per invocation, including retries
--max-duration SECONDS Unlimited Stop scheduling when the invocation duration limit is reached
--include-domain HOST All domains Include a hostname and its subdomains; repeatable
--exclude-domain HOST None Exclude a hostname and its subdomains; repeatable
--extensions LIST All extensions URL path extensions separated by commas; repeatable
--no-dns DNS enabled Skip DNS resolution
--ipv6 Off Resolve IPv6 addresses alongside IPv4 for original hostnames
--dry-run Off Show planned work without requests or file changes
--resume SESSION_DIR None Resume using the session's saved settings
--compare PREVIOUS_DIR None Compare with an earlier session or legacy output folder

Exit codes

Code Meaning
0 All search jobs succeeded, with no DNS failures; valid empty results also count as success
1 Search, DNS, or storage failures occurred
2 Invalid arguments or session configuration
3 Paused by a request or duration limit; continue with --resume
130 Interrupted with Ctrl+C; saved work can be resumed

An attempt that fails but succeeds on retry can still produce a successful job. Failure counters retain those attempts. Check summary.json and errors.json to distinguish valid empty results from failed searches.

Testing

Run the offline regression suite:

python3 -m unittest discover -s tests -v

The suite covers URL parsing, engine selection, regional parameters, shared request spacing, retries, filtering, budgets, DNS timeouts, page checkpoint recovery, exports, comparisons, and the complete CLI flow. It uses mocked HTTP and DNS responses, so it needs no search-engine connection.

The test workflow runs on pushes and pull requests, using Python 3.10, 3.12, and 3.14 on Linux and Windows. It also checks the CLI help and a small dry-run. These are offline checks; a passing workflow does not establish live provider availability.

Live results depend on the engines' HTML, rate limits, and availability. Some domains have no IPv4 record or cannot be resolved. Use the tool for authorized research and asset inventory, and respect the search engines' terms and request limits.

TLS certificate verification stays enabled. If a network redirects a search provider to a filtering page, the script records the request failure. The session can be resumed when the provider is reachable again.

License

MIT · Copyright (c) 2026 jemtod

About

Public keyword URL and domain scanner

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages