Back to blog
Engineering

From Unknown Domain to Machine-Readable Graph: A Step-by-Step Guide to Website Mapping

Turning an unknown, messy domain into a clean, structured graph is the foundational step of any serious web extraction pipeline. Learn how to engineer a scalable mapping system.

G
GYD Team·Engineering
May 12, 20268 min read

When a human looks at a website, they see a visual hierarchy. When a machine looks at a website, it just sees chaos. Turning an unknown, messy domain into a clean, structured graph is the foundational step of any serious web extraction pipeline.

Here is how you engineer a mapping system that actually scales, without getting bogged down in edge cases.

Phase 1: The Reconnaissance (Sitemaps and Heuristics)

Don't brute-force what the target server will give you for free. Always check robots.txt first. Not necessarily for compliance, but because developers frequently leave direct paths to undocumented XML sitemaps right at the top of the file. Probe standard locations like /sitemap.xml or /sitemap_index.xml.

If sitemaps exist, parse them recursively. This gives you a massive, proxy-cheap baseline of the site's intended structure before you even look at an HTML document.

Phase 2: Lightweight Spidering

Sitemaps are notoriously unreliable—often outdated, incomplete, or cached aggressively. To catch the rest of the site, you need a spider. Drop the headless browser for this. Use a highly concurrent, standard HTTP client with HTTP/2 support to minimize connection overhead. Parse the href attributes out of the raw HTML using a fast DOM parser like Cheerio. You do not need to render the page to find outbound links.

Crucially, you need to implement strict depth limits and track visited URL hashes. Otherwise, you will inevitably fall into a crawler trap and get stuck traversing infinite dynamic URLs.

(Wondering when you DO need a headless browser? That comes later during the extraction phase—which is exactly where GYD's Fetch API takes over to handle CAPTCHAs and JS rendering.)

Phase 3: URL Normalization and Clustering

This is where raw HTML scraping becomes an actual map. You have to strip tracking parameters (?utm_source=..., ?session_id=...). If you skip this normalization step, your map will be artificially inflated by thousands of duplicate nodes pointing to the exact same content.

Once normalized, cluster the URLs by their path segments. Grouping URLs by their structural patterns allows you to instantly identify the core architecture:

// Input: Raw normalized URLs
[
  "/product/123", 
  "/product/456", 
  "/cart/items"
]

// Output: Clustered URL paths
{ 
  "/product/*": 2, 
  "/cart/*": 1 
}

Phase 4: Constructing the Graph

The final output of a mapping job shouldn't just be a flat text file of strings. It needs to be an actionable graph that explicitly shows relationships.

Using the GYD Map API, a single request discovers the URLs and handles all the raw extraction, providing you with a clean payload of normalized links that you can then easily cluster downstream.

First, submit the domain. This returns a queued job ID:

curl -X POST https://gyd.ai/api/v1/map \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example-retailer.com", "fast_mode": true}'

Then, poll once mapping completes (typically in minutes, not hours):

curl https://gyd.ai/api/v1/map/<job_id> \
  -H "x-api-key: YOUR_API_KEY"

Response (after completion):

{
  "service": "map",
  "status": "completed",
  "source_url": "https://example-retailer.com",
  "final_url": "https://example-retailer.com",
  "total_links": 15420,
  "links_json_url": "<presigned B2 URL — valid for 24h>",
  "links_md_url": "<presigned B2 URL — valid for 24h>",
  "raw_html_url": "<presigned B2 URL — valid for 24h>",
  "sources": ["sitemap", "html"]
}

(Note: The Map API returns the comprehensive raw URL list via links_json_url. The clustering shape demonstrated in Phase 3 is what your downstream processor easily builds from it, allowing you to slice the data exactly how you need.)

By treating the website as a structural graph from day one, your scraping jobs become predictable, easier to debug, and highly resilient to frontend layout changes. You can dynamically instruct your extraction workers to ignore the /policies/* URLs and focus entirely on the /product/* endpoints.

If you don't want to build and maintain this mapping infrastructure yourself, you don't have to.

Try mapping any URL free on our playground (no signup needed) →


FAQ

What's the difference between mapping and crawling?
Mapping is the architectural discovery phase—identifying URLs and their structure. Crawling (or fetching) is the subsequent step where you download and extract the actual data from those URLs using tools like the GYD Crawl API.

How fast is mapping compared to crawling?
Because mapping skips heavy DOM rendering, downloading images, and executing JavaScript, it is orders of magnitude faster. A site that might take hours to fully crawl can often be mapped in a matter of minutes.

How do I integrate mapping into my scraping pipeline?
Run your Map API step on a schedule (e.g., weekly) to update your known URL graph. Then, pass the newly discovered product URLs into your daily extraction queue. For a full architecture guide, see our Documentation.