Got Scraping

4.2.1 · deprecated · verified Wed Apr 22

Got Scraping is an HTTP client built as an extension of the popular `got` library, specifically designed for web scraping tasks by making requests appear browser-like out of the box. It integrates features such as automatic browser-like header generation through the `header-generator` package, which allows for specifying desired browser, device, locale, and operating system profiles. It also simplifies proxy management, supporting HTTP and HTTPS proxies, including HTTP/2, and performs automatic ALPN negotiation for target servers. The package requires Node.js >=16 due to stability concerns with HTTP/2 in earlier versions. The current stable version is 4.2.1. However, as of its recent deprecation announcement, `got-scraping` is officially End-of-Life (EOL) and will no longer receive updates or support. For new projects, the maintainers strongly recommend migrating to `impit` (github.com/apify/impit), a modern, `fetch`-API-based HTTP client built on Rust's `reqwest` library, which offers a similar feature set and performance benefits.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates a basic GET request using `gotScraping` with proxy support and custom header generation options, showing how to fetch and log response data.

import { gotScraping } from 'got-scraping';

async function fetchExampleData() {
    try {
        const response = await gotScraping.get({
            url: 'https://httpbin.org/headers', // A simple endpoint to inspect request headers
            proxyUrl: process.env.PROXY_URL ?? 'http://username:password@proxy.example.com:8000',
            useHeaderGenerator: true,
            headerGeneratorOptions: {
                browsers: [
                    { name: 'chrome', minVersion: 90, maxVersion: 99 }
                ],
                devices: ['desktop'],
                locales: ['en-US', 'de-DE'],
                operatingSystems: ['windows', 'macos']
            },
            // Standard Got options are also available
            timeout: { request: 30000 }, // 30-second total request timeout
            retry: { limit: 2, methods: ['GET'] }, // Retry GET requests up to 2 times
            headers: {
                'X-Custom-Header': 'Scraping-Demo-Request'
            }
        });

        console.log('Status Code:', response.statusCode);
        console.log('Response Body (first 500 chars):', response.body.substring(0, 500));
        // Further processing of `response.body` (e.g., JSON.parse) would happen here.
    } catch (error) {
        console.error('Failed to fetch data:', error instanceof Error ? error.message : error);
    }
}

fetchExampleData();

view raw JSON →