{"id":51232180,"url":"https://github.com/xcrap-dev/impit-client","last_synced_at":"2026-06-28T17:02:06.335Z","repository":{"id":306474324,"uuid":"1026303206","full_name":"xcrap-dev/impit-client","owner":"xcrap-dev","description":"Xcrap Impit Client is a package within the Xcrap framework that implements an HTTP client using the Impit library.","archived":false,"fork":false,"pushed_at":"2026-03-12T00:35:41.000Z","size":510,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-12T14:52:28.326Z","etag":null,"topics":["client","http","impit","scraping","web","xcrap"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@xcrap/impit-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-07-25T16:44:52.000Z","updated_at":"2026-03-05T03:21:51.000Z","dependencies_parsed_at":"2025-07-26T00:03:07.212Z","dependency_job_id":"dbec2336-fc20-4b1d-942e-59888b87368d","html_url":"https://github.com/xcrap-dev/impit-client","commit_stats":null,"previous_names":["xcrap-cloud/impit-client","xcrap-dev/impit-client"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xcrap-dev/impit-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Fimpit-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Fimpit-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Fimpit-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Fimpit-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xcrap-dev","download_url":"https://codeload.github.com/xcrap-dev/impit-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Fimpit-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34896652,"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-28T02:00:05.809Z","response_time":54,"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","http","impit","scraping","web","xcrap"],"created_at":"2026-06-28T17:02:05.411Z","updated_at":"2026-06-28T17:02:06.327Z","avatar_url":"https://github.com/xcrap-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🕷️ Xcrap Impit Client\n\n**Xcrap Impit Client** is a package within the Xcrap framework that implements an HTTP client using the [Impit](https://www.npmjs.com/package/impit) 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/impit-client @xcrap/core @xcrap/extractor\n```\n\n\u003e You also need to install `@xcrap/extractor` and `@xcrap/core` because they are listed as `peerDependencies`. This means the package requires `@xcrap/extractor` and `@xcrap/core`, but it will use the versions that the user has installed in their project.\n\n-----\n\n## 🚀 Usage\n\nLike all HTTP clients, `ImpitClient` has two methods: `fetch()` to make a request to a specific URL and `fetchMany()` to make requests to multiple URLs simultaneously, with control over concurrency and delays between requests.\n\n### Usage Example\n\n```ts\nimport { ImpitClient } from \"@xcrap/impit-client\"\nimport { extract, css } from \"@xcrap/extractor\"\n\n;(async () =\u003e {\n    const client = new ImpitClient()\n    const url = \"https://example.com\"\n    const response = await client.fetch({ url: url })\n    const parser = response.asHtmlParser()\n    const pageTitle = await parser.extractValue({ query: css(\"title\"), extractor: extract(\"innerText\") })\n\n    console.log(\"Page Title:\", pageTitle)\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 examples:\n\n1.  **Providing a `proxy` string**:\n\n    ```ts\n    const client = new ImpitClient({ proxy: \"http://47.251.122.81:8888\" })\n    ```\n\n2.  **Providing a function that generates 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\n    \tconst randomIndex = Math.floor(Math.random() * proxies.length)\n\n    \treturn proxies[randomIndex]\n    }\n\n    const client = new ImpitClient({ 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 ImpitClient({ 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 generates 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\n    \tconst randomIndex = Math.floor(Math.random() * userAgents.length)\n\n    \treturn userAgents[randomIndex]\n    }\n\n    const client = new ImpitClient({ userAgent: randomUserAgent })\n    ```\n\n### Using a Custom Proxy URL\n\nIn a client that extends `BaseClient`, you can use proxy URLs. While the exact explanation of how they work might be complex, I encountered this type of proxy when trying to solve CORS issues by making client-side requests, and that's how I learned about *CORS Proxy*. Here's a [template](https://gist.github.com/marcuth/9fbd321b011da44d1287faae31a8dd3a) for a CloudFlare Workers implementation if you want to set up your own.\n\nYou can configure this in the same way we configured `userAgent`:\n\n1.  **Providing a `proxyUrl` string**:\n\n    ```ts\n    const client = new ImpitClient({ proxyUrl: \"https://my-proxy-app.my-username.workers.dev\" })\n    ```\n\n2.  **Providing a function that generates 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\n    \tconst randomIndex = Math.floor(Math.random() * proxyUrls.length)\n\n    \treturn proxyUrls[randomIndex]\n    }\n\n    const client = new ImpitClient({ 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\nWant to contribute? Follow these steps:\n\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%2Fimpit-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxcrap-dev%2Fimpit-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcrap-dev%2Fimpit-client/lists"}