{"id":50228894,"url":"https://github.com/xcrap-dev/puppeteer-extra-client","last_synced_at":"2026-06-01T09:01:35.141Z","repository":{"id":286315107,"uuid":"961041963","full_name":"xcrap-dev/puppeteer-extra-client","owner":"xcrap-dev","description":"Xcrap Puppeteer Extra Client is a package of the Xcrap framework that implements an HTTP client using the Puppeteer Extra library.","archived":false,"fork":false,"pushed_at":"2026-05-21T04:52:38.000Z","size":190,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-26T17:39:24.529Z","etag":null,"topics":["client","extra","http","javascript","nodejs","puppeteer","scraping","typescript","web","xcrap"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@xcrap/puppeteer-extra-client","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xcrap-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-05T16:18:44.000Z","updated_at":"2026-02-26T06:30:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"8176e4f9-5ff6-44eb-ac80-8c42a7c48edd","html_url":"https://github.com/xcrap-dev/puppeteer-extra-client","commit_stats":null,"previous_names":["xcrap-cloud/puppeteer-extra-client","xcrap-dev/puppeteer-extra-client"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xcrap-dev/puppeteer-extra-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Fpuppeteer-extra-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Fpuppeteer-extra-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Fpuppeteer-extra-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Fpuppeteer-extra-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xcrap-dev","download_url":"https://codeload.github.com/xcrap-dev/puppeteer-extra-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Fpuppeteer-extra-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33767439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["client","extra","http","javascript","nodejs","puppeteer","scraping","typescript","web","xcrap"],"created_at":"2026-05-26T17:32:49.868Z","updated_at":"2026-06-01T09:01:34.904Z","avatar_url":"https://github.com/xcrap-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🕷️ Xcrap Puppeteer Extra Client\n\n**Xcrap Puppeteer Extra Client** is an [Xcrap](https://www.npmjs.com/package/xcrap) framework package that implements an HTTP client using the [Puppeteer Extra](https://www.npmjs.com/package/puppeteer-extra) library.\n\n-----\n\n## 📦 Installation\n\nInstallation is straightforward; just use your preferred dependency manager. Here's an example using NPM:\n\n```cmd\nnpm i @xcrap/puppeteer-extra-client @xcrap/core @xcrap/parser\n```\n\n\u003e You also need to install `@xcrap/parser` and `@xcrap/core` because they are `peerDependencies`. This means the package requires `@xcrap/parser` and `@xcrap/core` as dependencies, but it will use the versions the user has installed in their project.\n\n-----\n\n## 🚀 Usage\n\nLike all HTTP clients, `PuppeteerExtraClient` has two methods: `fetch()` to make a request to a specific URL, and `fetchMany()` to make requests to multiple URLs simultaneously, allowing control over concurrency and delays between requests.\n\n### Usage Example\n\n```ts\nimport { PuppeteerExtraClient } from \"@xcrap/puppeteer-extra-client\"\nimport { extract } from \"@xcrap/parser\"\n\n;(async () =\u003e {\n    const client = new PuppeteerExtraClient()\n    const url = \"https://example.com\"\n    const response = await client.fetch({ url: url })\n    const parser = response.asHtmlParser()\n    const pageTitle = await parser.parseFist({ query: \"title\", extractor: extract(\"innerText\") })\n\n    console.log(\"Page Title:\", pageTitle)\n})();\n```\n\n### Using Plugins\n\nAs the main feature of `puppeteer-extra`, you can use plugins in the constructor as follows:\n\n```ts\nimport { PuppeteerExtraClient } from \"@xcrap/puppeteer-extra-client\"\nconst StealthPlugin = require(\"puppeteer-extra-plugin-stealth\")\n\nconst client = new PuppeteerExtraClient({\n\tplugins: [StealthPlugin()]\n})\n```\n\nOr, if you've previously instantiated a client:\n\n```ts\nclient.usePlugin(StealthPlugin())\n```\n\n### Using Actions\n\nIf you want to perform operations on the page before or after requests, you can use the `actions` property, which is an array of functions. Actions are flexible enough for you to do exactly what you would normally do with Puppeteer: log in, click buttons, evaluate functions, etc.\n\n```ts\nconst response = await client.fetch({\n\turl: \"https://example.com\",\n\tactions: [\n\t\tasync (page) =\u003e {\n\t\t\tawait page.type(\"#username\", \"user\")\n\t\t\tawait page.type(\"#password\", \"mypassword123\")\n\t\t\tawait page.click(\"#submit\")\n\t\t}\n\t]\n})\n```\n\nBy default, an action is executed after the request. If you want to manually define when it should be executed, you'll need to pass an object instead of a simple function:\n\n```ts\nconst response = await client.fetch({\n\turl: \"https://example.com\",\n\tactions: [\n\t\t{\n\t\t\ttype: \"afterRequest\", // Executed after the request\n\t\t\texec: async (page) =\u003e {\n\t\t\t\tawait page.type(\"#username\", \"user\")\n\t\t\t\tawait page.type(\"#password\", \"mypassword123\")\n\t\t\t\tawait page.click(\"#submit\")\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\ttype: \"beforeRequest\", // Executed before the request\n\t\t\tfunc: async (page) =\u003e {\n\t\t\t\tconst width = 1920 + Math.floor(Math.random() * 100)\n\t\t\t\tconst height = 3000 + Math.floor(Math.random() * 100)\n\t\t\n\t\t\t\tawait page.setViewport({\n\t\t\t\t\twidth: width,\n\t\t\t\t\theight: height,\n\t\t\t\t\tdeviceScaleFactor: 1,\n\t\t\t\t\thasTouch: false,\n\t\t\t\t\tisLandscape: false,\n\t\t\t\t\tisMobile: false,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t]\n})\n```\n\n### Adding a Proxy\n\nIn an HTTP client that extends `BaseClient`, you can add a proxy in the constructor, as shown in the following example:\n\n1.  **Providing a `proxy` string**:\n\n    ```ts\n    const client = new PuppeteerExtraClient({ proxy: \"http://47.251.122.81:8888\" })\n    ```\n\n2.  **Providing a function that will generate a `proxy`**:\n\n    ```ts\n    function randomProxy() {\n    \tconst proxies = [\n    \t\t\"http://47.251.122.81:8888\",\n    \t\t\"http://159.203.61.169:3128\"\n    \t]\n    \t\n    \tconst randomIndex = Math.floor(Math.random() * proxies.length)\n    \t\n    \treturn proxies[randomIndex]\n    }\n\n    const client = new PuppeteerExtraClient({ proxy: randomProxy })\n    ```\n\n### Using a Custom User Agent\n\nIn a client that extends `BaseClient`, you can also customize the `User-Agent` for requests. You can do this in two ways:\n\n1.  **Providing a `userAgent` string**:\n\n    ```ts\n    const client = new PuppeteerExtraClient({ userAgent: \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36\" })\n    ```\n\n2.  **Providing a function that will generate a `userAgent`**:\n\n    ```ts\n    function randomUserAgent() {\n    \tconst userAgents = [\n    \t\t\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_8_4; like Mac OS X) AppleWebKit/603.37 (KHTML, like Gecko)  Chrome/54.0.1244.188 Mobile Safari/601.5\",\n    \t\t\"Mozilla/5.0 (Windows NT 10.3;; en-US) AppleWebKit/537.35 (KHTML, like Gecko) Chrome/47.0.1707.185 Safari/601\"\n    \t]\n    \t\n    \tconst randomIndex = Math.floor(Math.random() * userAgents.length)\n    \t\n    \treturn userAgents[randomIndex]\n    }\n\n    const client = new PuppeteerExtraClient({ userAgent: randomUserAgent })\n    ```\n\n### Using a Custom Proxy URL\n\nIn a client that extends `BaseClient`, you can use proxy URLs. I'm not entirely sure how best to explain how they work, but I stumbled upon this type of proxy when trying to solve a CORS issue by making a client-side request, and that's when I learned about *CORS Proxy*. Here's a [template](https://gist.github.com/marcuth/9fbd321b011da44d1287faae31a8dd3a) for a Cloudflare Workers proxy if you want to set up your own.\n\nYou can set it up the same way we did with the `userAgent`:\n\n1.  **Providing a `proxyUrl` string**:\n\n    ```ts\n    const client = new PuppeteerExtraClient({ proxyUrl: \"https://my-proxy-app.my-username.workers.dev\" })\n    ```\n\n2.  **Providing a function that will generate a `proxyUrl`**:\n\n    ```ts\n    function randomProxyUrl() {\n    \tconst proxyUrls = [\n    \t\t\"https://my-proxy-app.my-username-1.workers.dev\",\n    \t\t\"https://my-proxy-app.my-username-2.workers.dev\"\n    \t]\n    \t\n    \tconst randomIndex = Math.floor(Math.random() * proxyUrls.length)\n    \t\n    \treturn proxyUrls[randomIndex]\n    }\n\n    const client = new PuppeteerClient({ proxyUrl: randomProxyUrl })\n    ```\n\n-----\n\n## 🧪 Tests\n\nAutomated tests are located in `__tests__`. To run them:\n\n```bash\nnpm run test\n```\n\n-----\n\n## 🤝 Contributing\n\n  - Want to contribute? Follow these steps:\n  - Fork the repository.\n  - Create a new branch (git checkout -b feature-new).\n  - Commit your changes (git commit -m 'Add new feature').\n  - Push to the branch (git push origin feature-new).\n  - Open a Pull Request.\n\n-----\n\n## 📝 License\n\nThis project is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcrap-dev%2Fpuppeteer-extra-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxcrap-dev%2Fpuppeteer-extra-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcrap-dev%2Fpuppeteer-extra-client/lists"}