Skip to content

06 Telemetry and Scraping Engine

Vicky Patel edited this page Nov 18, 2026 · 1 revision

06. Telemetry & Scraping Engine

Reverse-Engineering GitHub Profile Modals, Parsing Milestones, and Resilient HTTP Ingestion


๐Ÿ”ฌ Why Scraping is Required

As established in earlier chapters, GitHub provides zero native REST or GraphQL endpoints for achievements. While an unauthenticated GET to https://api.github.com/users/{username} yields basic biographical information, it contains no achievement nodes.

However, GitHub's public web interface renders achievements on user profiles and allows users to click into each badge to view an achievement history modal:

https://github.com/users/{username}/achievements/{badge_slug}

GitVerse's internal/github package bridges this gap by executing an automated, highly optimized HTML scraping and telemetry extraction pipeline.


โš™๏ธ The Scraping Pipeline Architecture

graph TD
    Start[User Submits Handle] --> FetchProfile[GET /username?tab=achievements]
    FetchProfile --> ParseList[Parse Unlocked Badges & Tier Badges]
    ParseList --> Filter[Filter Valid Badge Slugs]
    Filter --> DetailFanOut[Async Fetch /users/username/achievements/slug]
    DetailFanOut --> ParseModal[Extract Unlock Timestamps & Milestone Counts]
    ParseModal --> Reconcile[Reconcile with Catalog Rules]
    Reconcile --> EngineResult[Final Aggregated Report]
Loading

๐Ÿ” HTML Scraping Mechanics & Selectors

GitVerse uses Go's standard golang.org/x/net/html token parser. This avoids bloated headless browser dependencies (like Puppeteer or Playwright), ensuring sub-second response times:

1. Parsing the Main Achievement Shelf

When scraping https://github.com/{username}?tab=achievements:

  • GitVerse searches for the <div class="achievement-badge-container"> nodes.
  • Extracts alt or title attributes corresponding to canonical badge identifiers.
  • Captures badge tier multipliers (e.g., x2, x3, x4 badge rings).

2. Extracting Detail Modals

For each detected achievement, GitVerse requests the individual badge history fragment:

GET /users/{username}/achievements/{badge_slug} HTTP/1.1
Host: github.com
User-Agent: GitVerse-Engine/1.0 (+https://mygitverse.vercel.app)
Accept: text/html

Inside this fragment, GitHub renders:

  • The exact UTC timestamp when each tier was awarded (<relative-time datetime="...">).
  • The repository in which the milestone was reached (e.g., TheVicky1/GitVerse).
  • The milestone pull request or discussion number (e.g., #42).

๐Ÿ›ก๏ธ Anti-Flake & Rate Limit Protection

Public scraping against GitHub requires strict operational safeguards:

1. Intelligent Request Batching

GitVerse does not make synchronous sequential calls; nor does it execute uncontrolled parallel floods. It utilizes a Go worker pool with a maximum concurrency limit ($\le 4$ simultaneous connections per user request) to prevent GitHub firewalls from flagging the incoming IP.

2. Header Mimicry & Connection Pooling

Requests originate from a persistent http.Transport with HTTP/2 enabled, TCP keep-alive, and an authentic browser User-Agent string alongside standard Accept-Language headers.

3. Jittered Exponential Backoff

If GitHub returns an HTTP 429 Too Many Requests or 403 Forbidden, the engine pauses using exponential backoff with full jitter: $$t_{\text{wait}} = \min(t_{\text{max}}, 2^n \times t_{\text{base}} + \text{jitter})$$

4. Bot Token Fallback Layer

On the Vercel web deployment, when public scraping encounters IP exhaustion, GitVerse transparently falls back to an authenticated GitHub Bot Token (GH_BOT_TOKEN) to retrieve repository and user metadata via the REST API to cross-calibrate missing metrics.

Clone this wiki locally