Scrape SDK
Guides

Offline testing

Inject fetch or use the local adapter.

View Markdown
import { createScrapeClient } from "scrape-sdk";
import { local } from "scrape-sdk/local";

const scraper = createScrapeClient({
  provider: local({
    fetch: async (url) => new Response("<html><article><h1>Hi</h1></article></html>", {
      headers: { "content-type": "text/html" },
    }),
  }),
});

const page = await scraper.scrape("https://example.com");

Every adapter accepts fetch in its config so tests can pin real request URLs and JSON shapes without the network.