Web Scraping via API Interception

VerifiedSafe

Intercept and replay API network requests to scrape large datasets efficiently. By capturing request headers and response schemas, you bypass slow DOM scrolling and directly fetch structured data with automatic pagination. Ideal for collecting followers, posts, or search results from web applications.

Sby Skills Guide Bot
Data & AIIntermediate
6/2/2026
Claude CodeCursorWindsurfCopilotCodex
#data-scraping#api-replay#pagination#web-automation

Recommended for

Automated summary

A guide for extracting large datasets from websites by intercepting and replaying API requests with pagination, instead of scrolling and parsing the DOM.

Strengths

  • Faster and more reliable than DOM scrolling
  • Automatic pagination handling via APIs
  • Incremental approach reduces debugging errors
  • Direct access to structured data

Limitations

  • Requires understanding of target API schemas
  • Depends on browser and network interception
  • May be blocked by anti-scraping measures or API changes
When to use it

When you need to collect large volumes of structured data from websites that have underlying APIs.

When not to use it

When the site does not expose an API or authentication is difficult to replicate, or for small extractions that can be done manually.

Security analysis

Safe
Quality score92/100

The skill describes data scraping via browser API replay, with no destructive or exfiltrating actions. It uses browser automation for legitimate purposes, includes rate limiting, and stores data locally.

No concerns found

How this analysis is made

Examples

Scrape Twitter profile tweets via API
Write a script to intercept the UserTweets API endpoint on a Twitter profile page, capture the response schema, and replay requests with cursor pagination to extract all tweets (id, text, timestamp).
Extract product listings from e-commerce site
I need to scrape product listings from an e-commerce site. Use network interception to capture the API call that returns product data, then replay it with pagination to gather all products.
Automate data extraction from a paginated API
Create a browser automation script that intercepts network requests, identifies a paginated API endpoint, and recursively fetches all pages while handling cursors and rate limiting.

Data Scraping Guide

For large datasets (followers, posts, search results), intercept and replay network requests rather than scrolling and parsing the DOM. This is faster, more reliable, and handles pagination automatically.

Why Not Scroll?

Scrolling is slow, unreliable, and wastes time. APIs return structured data with pagination built in. Always prefer API replay.

Start Small, Then Scale

Don't try to automate everything at once. Work incrementally:

  1. Capture one request - verify you're intercepting the right endpoint
  2. Inspect one response - understand the schema before writing extraction code
  3. Extract a few items - make sure your parsing logic works
  4. Then scale up - add pagination loop only after the basics work

This prevents wasting time debugging a complex script when the issue is a simple path like data.user.timeline vs data.user.result.timeline.

Step-by-Step Workflow

1. Capture Request Details

First, intercept a request to understand URL structure and required headers:

import { connect, waitForPageLoad } from "@/client.js";
import * as fs from "node:fs";

const client = await connect();
const page = await client.page("site");

let capturedRequest = null;
page.on("request", (request) => {
  const url = request.url();
  // Look for API endpoints (adjust pattern for your target site)
  if (url.includes("/api/") || url.includes("/graphql/")) {
    capturedRequest = {
      url: url,
      headers: request.headers(),
      method: request.method(),
    };
    fs.writeFileSync("tmp/request-details.json", JSON.stringify(capturedRequest, null, 2));
    console.log("Captured request:", url.substring(0, 80) + "...");
  }
});

await page.goto("https://example.com/profile");
await waitForPageLoad(page);
await page.waitForTimeout(3000);

await client.disconnect();

2. Capture Response to Understand Schema

Save a raw response to inspect the data structure:

page.on("response", async (response) => {
  const url = response.url();
  if (url.includes("UserTweets") || url.includes("/api/data")) {
    const json = await response.json();
    fs.writeFileSync("tmp/api-response.json", JSON.stringify(json, null, 2));
    console.log("Captured response");
  }
});

Then analyze the structure to find:

  • Where the data array lives (e.g., data.user.result.timeline.instructions[].entries)
  • Where pagination cursors are (e.g., cursor-bottom entries)
  • What fields you need to extract

3. Replay API with Pagination

Once you understand the schema, replay requests directly:

import { connect } from "@/client.js";
import * as fs from "node:fs";

const client = await connect();
const page = await client.page("site");

const results = new Map(); // Use Map for deduplication
const headers = JSON.parse(fs.readFileSync("tmp/request-details.json", "utf8")).headers;
const baseUrl = "https://example.com/api/data";

let cursor = null;
let hasMore = true;

while (hasMore) {
  // Build URL with pagination cursor
  const params = { count: 20 };
  if (cursor) params.cursor = cursor;
  const url = `${baseUrl}?params=${encodeURIComponent(JSON.stringify(params))}`;

  // Execute fetch in browser context (has auth cookies/headers)
  const response = await page.evaluate(
    async ({ url, headers }) => {
      const res = await fetch(url, { headers });
      return res.json();
    },
    { url, headers }
  );

  // Extract data and cursor (adjust paths for your API)
  const entries = response?.data?.entries || [];
  for (const entry of entries) {
    if (entry.type === "cursor-bottom") {
      cursor = entry.value;
    } else if (entry.id && !results.has(entry.id)) {
      results.set(entry.id, {
        id: entry.id,
        text: entry.content,
        timestamp: entry.created_at,
      });
    }
  }

  console.log(`Fetched page, total: ${results.size}`);

  // Check stop conditions
  if (!cursor || entries.length === 0) hasMore = false;

  // Rate limiting - be respectful
  await new Promise((r) => setTimeout(r, 500));
}

// Export results
const data = Array.from(results.values());
fs.writeFileSync("tmp/results.json", JSON.stringify(data, null, 2));
console.log(`Saved ${data.length} items`);

await client.disconnect();

Key Patterns

| Pattern | Description | | ----------------------- | ------------------------------------------------------ | | page.on('request') | Capture outgoing request URL + headers | | page.on('response') | Capture response data to understand schema | | page.evaluate(fetch) | Replay requests in browser context (inherits auth) | | Map for deduplication | APIs often return overlapping data across pages | | Cursor-based pagination | Look for cursor, next_token, offset in responses |

Tips

  • Extension mode: page.context().cookies() doesn't work - capture auth headers from intercepted requests instead
  • Rate limiting: Add 500ms+ delays between requests to avoid blocks
  • Stop conditions: Check for empty results, missing cursor, or reaching a date/ID threshold
  • GraphQL APIs: URL params often include variables and features JSON objects - capture and reuse them

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/web-scraping-via-api-interception-mm5t8chf/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/web-scraping-via-api-interception-mm5t8chf' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/web-scraping-via-api-interception-mm5t8chf/download' --output '.skill-downloads/web-scraping-via-api-interception-mm5t8chf/SKILL.md.part' && mv '.skill-downloads/web-scraping-via-api-interception-mm5t8chf/SKILL.md.part' '.skill-downloads/web-scraping-via-api-interception-mm5t8chf/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/web-scraping-via-api-interception-mm5t8chf/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills