{"id":13859183,"url":"https://github.com/apify/got-scraping","last_synced_at":"2025-11-03T16:29:56.827Z","repository":{"id":37928820,"uuid":"343885315","full_name":"apify/got-scraping","owner":"apify","description":"HTTP client made for scraping based on got.","archived":false,"fork":false,"pushed_at":"2025-03-31T11:16:33.000Z","size":312,"stargazers_count":671,"open_issues_count":16,"forks_count":50,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-08T05:44:24.485Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apify.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-03-02T19:15:26.000Z","updated_at":"2025-05-07T21:55:04.000Z","dependencies_parsed_at":"2023-01-21T12:34:08.464Z","dependency_job_id":"8abd82bf-7754-4605-b86a-c5f91888d91b","html_url":"https://github.com/apify/got-scraping","commit_stats":{"total_commits":148,"total_committers":13,"mean_commits":"11.384615384615385","dds":0.6283783783783784,"last_synced_commit":"8d9808acd5c37fe1f0050091f82b9a836299ffd8"},"previous_names":[],"tags_count":97,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fgot-scraping","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fgot-scraping/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fgot-scraping/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fgot-scraping/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apify","download_url":"https://codeload.github.com/apify/got-scraping/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254052692,"owners_count":22006716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-05T03:02:35.727Z","updated_at":"2025-11-03T16:29:56.822Z","avatar_url":"https://github.com/apify.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","📡 HTTP Clients"],"sub_categories":["Ruby"],"readme":"\u003e # ⚠️⚠️⚠️ `got-scraping` is EOL ⚠️⚠️⚠️\n\u003e\n\u003e After many years of development, we decided to deprecate the `got-scraping` package.\n\u003e The package will no longer receive updates or support.\n\u003e\n\u003e For new projects, we recommend using [`impit`](https://github.com/apify/impit). `impit` is a modern, powerful, and flexible HTTP client with `fetch` API based on Rust's `reqwest` library. It provides a similar feature set to `got-scraping`, including browser-like request headers, proxy support, and more.\n\u003e\n\n\n## Got Scraping\n\nGot Scraping is a small but powerful [`got` extension](https://github.com/sindresorhus/got) with the purpose of sending browser-like requests out of the box. This is very essential in the web scraping industry to blend in with the website traffic.\n\n## Installation\n\n```\n$ npm install got-scraping\n```\n\n# The module is now ESM only\n\nThis means you have to import it by using an `import` expression, or the `import()` method. You can do so by either migrating your project to ESM, or importing `got-scraping` in an async context\n\n```diff\n-const { gotScraping } = require('got-scraping');\n+import { gotScraping } from 'got-scraping';\n```\n\nIf you cannot migrate to ESM, here's an example of how to import it in an async context:\n\n```javascript\nlet gotScraping;\n\nasync function fetchWithGotScraping(url) {\n    gotScraping ??= (await import('got-scraping')).gotScraping;\n\n    return gotScraping.get(url);\n}\n```\n\n**Note:**\n\u003e - Node.js \u003e=16 is required due to instability of HTTP/2 support in lower versions.\n\n## API\n\nGot scraping package is built using the [`got.extend(...)`](https://github.com/sindresorhus/got/blob/main/documentation/10-instances.md) functionality, therefore it supports all the features Got has.\n\nInterested what's [under the hood](#under-the-hood)?\n\n```javascript\nimport { gotScraping } from 'got-scraping';\n\ngotScraping\n    .get('https://apify.com')\n    .then( ({ body }) =\u003e console.log(body));\n```\n\n### options\n\n#### `proxyUrl`\n\nType: **`string`**\n\nURL of the HTTP or HTTPS based proxy. HTTP/2 proxies are supported as well.\n\n```javascript\nimport { gotScraping } from 'got-scraping';\n\ngotScraping\n    .get({\n        url: 'https://apify.com',\n        proxyUrl: 'http://usernamed:password@myproxy.com:1234',\n    })\n    .then(({ body }) =\u003e console.log(body));\n```\n\n#### `useHeaderGenerator`\n\nType: **`boolean`**\\\nDefault: **`true`**\n\nWhether to use the generation of the browser-like headers.\n\n#### `headerGeneratorOptions`\n\nSee the [`HeaderGeneratorOptions`](https://github.com/apify/fingerprint-suite/tree/master/packages/header-generator#headergeneratoroptions) docs.\n\n```javascript\nconst response = await gotScraping({\n    url: 'https://api.apify.com/v2/browser-info',\n    headerGeneratorOptions:{\n        browsers: [\n            {\n                name: 'chrome',\n                minVersion: 87,\n                maxVersion: 89\n            }\n        ],\n        devices: ['desktop'],\n        locales: ['de-DE', 'en-US'],\n        operatingSystems: ['windows', 'linux'],\n    }\n});\n```\n\n#### `sessionToken`\n\nA non-primitive unique object which describes the current session. By default, it's `undefined`, so new headers will be generated every time. Headers generated with the same `sessionToken` never change.\n\n## Under the hood\n\nThanks to the included [`header-generator`](https://github.com/apify/fingerprint-suite/tree/master/packages/header-generator) package, you can choose various browsers from different operating systems and devices. It generates all the headers automatically so you can focus on the important stuff instead.\n\nYet another goal is to simplify the usage of proxies. Just pass the `proxyUrl` option and you are set. Got Scraping automatically detects the HTTP protocol that the proxy server supports. After the connection is established, it does another ALPN negotiation for the end server. Once that is complete, Got Scraping can proceed with HTTP requests.\n\nUsing the same HTTP version that browsers do is important as well. Most modern browsers use HTTP/2, so Got Scraping is making a use of it too. Fortunately, this is already supported by Got - it automatically handles [ALPN protocol negotiation](https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation) to select the best available protocol.\n\nHTTP/1.1 headers are always automatically formatted in [`Pascal-Case`](https://pl.wikipedia.org/wiki/PascalCase). However, there is an exception: [`x-`](https://datatracker.ietf.org/doc/html/rfc7231#section-8.3.1) headers are not modified in *any* way.\n\nBy default, Got Scraping will use an insecure HTTP parser, which allows to access websites with non-spec-compliant web servers.\n\nLast but not least, Got Scraping comes with updated TLS configuration. Some websites make a fingerprint of it and compare it with real browsers. While Node.js doesn't support OpenSSL 3 yet, the current configuration still should work flawlessly.\n\nTo get more detailed information about the implementation, please refer to the [source code](https://github.com/apify/got-scraping/blob/master/src/index.ts).\n\n## Tips\n\nThis package can only generate all the standard attributes. You might want to add the [`referer` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer) if necessary. Please bear in mind that these headers are made for GET requests for HTML documents. If you want to make POST requests or GET requests for any other content type, you should alter these headers according to your needs. You can do so by passing a headers option or writing a custom [Got handler](https://github.com/sindresorhus/got/blob/main/documentation/10-instances.md).\n\nThis package should provide a solid start for your browser request emulation process. All websites are built differently, and some of them might require some additional special care.\n\n### Overriding request headers\n\n```javascript\nconst response = await gotScraping({\n    url: 'https://apify.com/',\n    headers: {\n        'user-agent': 'test',\n    },\n});\n```\n\nFor more advanced usage please refer to the [Got documentation](https://github.com/sindresorhus/got/#documentation).\n\n### JSON mode\n\nYou can parse JSON with this package too, but please bear in mind that the request header generation is done specifically for `HTML` content type. You might want to alter the generated headers to match the browser ones.\n\n```javascript\nconst response = await gotScraping({\n    responseType: 'json',\n    url: 'https://api.apify.com/v2/browser-info',\n});\n```\n\n### Error recovery\n\nThis section covers possible errors that might happen due to different site implementations.\n\n```\nRequestError: Client network socket disconnected before secure TLS connection was established\n```\n\nThe error above can be a result of the server not supporting the provided TLS setings. Try changing the ciphers parameter to either `undefined` or a custom value.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapify%2Fgot-scraping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapify%2Fgot-scraping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapify%2Fgot-scraping/lists"}