{"id":26951522,"url":"https://github.com/xcrap-cloud/got-scraping-client","last_synced_at":"2025-08-21T11:17:59.640Z","repository":{"id":285816480,"uuid":"959414201","full_name":"Xcrap-Cloud/got-scraping-client","owner":"Xcrap-Cloud","description":"Xcrap Got Scraping Client is a package of the Xcrap framework that implements an HTTP client using the Got Scraping library.","archived":false,"fork":false,"pushed_at":"2025-06-17T04:48:39.000Z","size":58,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-21T11:03:26.559Z","etag":null,"topics":["client","got","http","javascript","nodejs","scraping","scrapy","typescript","web","xcrap"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@xcrap/got-scraping-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-Cloud.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}},"created_at":"2025-04-02T18:43:40.000Z","updated_at":"2025-06-17T04:48:42.000Z","dependencies_parsed_at":"2025-04-09T15:16:20.322Z","dependency_job_id":"341ed1cc-7676-410f-a823-f2a8c1bbf715","html_url":"https://github.com/Xcrap-Cloud/got-scraping-client","commit_stats":null,"previous_names":["xcrap-cloud/got-scraping-client"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Xcrap-Cloud/got-scraping-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xcrap-Cloud%2Fgot-scraping-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xcrap-Cloud%2Fgot-scraping-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xcrap-Cloud%2Fgot-scraping-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xcrap-Cloud%2Fgot-scraping-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xcrap-Cloud","download_url":"https://codeload.github.com/Xcrap-Cloud/got-scraping-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xcrap-Cloud%2Fgot-scraping-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271469227,"owners_count":24765124,"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","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"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","got","http","javascript","nodejs","scraping","scrapy","typescript","web","xcrap"],"created_at":"2025-04-03T00:16:21.683Z","updated_at":"2025-08-21T11:17:59.635Z","avatar_url":"https://github.com/Xcrap-Cloud.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🕷️ Xcrap Got Scraping Client\n\n**Xcrap Got Scraping Client** is a package of the Xcrap framework that implements an HTTP client using the [Got Scraping](https://www.npmjs.com/package/got-scraping) library.\n\n## 📦 Installation\n\nThere are no secrets to installing it, just use your favorite dependency manager. Here is an example using NPM:\n\n```cmd\nnpm i @xcrap/got-scraping-client @xcrap/core @xcrap/parser\n```\n\n\u003e You need to install `@xcrap/parser` and `@xcrap/core` as well because I left them as `peerDependencies`, which means that the package needs `@xcrap/parser` and `@xcrap/core` as dependencies, however, the ones that the user has installed in the project will be used.\n\n## 🚀 Usage\n\nLike any HTTP client, `GotScrapingClient` has two methods: `fetch()` to make a request for a specific URL and `fetchMany()` to make requests for multiple URLs at the same time, being able to control concurrency and delays between requests. ### Example usage\n\n```ts\nimport { GotScrapingClient } from \"@xcrap/got-scraping-client\"\nimport { extract } from \"@xcrap/parser\"\n\n;(async() =\u003e {\n    const client = new GotScrapingClient()\n    const url = \"https://example.com\"\n    const response = await client.fetch({ url: url })\n    const parser = response.asHtmlParser()\n    const pageTitle = await parser.parseFirst({ query: \"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` we can add a proxy in the constructor as we can see in the following example:\n\n1. **Providing a `proxy` string**:\n\n```ts\nconst client = new GotScrapingClient({ proxy: \"http://47.251.122.81:8888\" })\n```\n\n2. **Providing a function that will generate a `proxy`**:\n\n```ts\nfunction randomProxy() {\n    const proxies = [\n        \"http://47.251.122.81:8888\",\n        \"http://159.203.61.169:3128\"\n    ]\n\n    const randomIndex = Math.floor(Math.random() * proxies.length)\n\n    return proxies[randomIndex]\n}\n\nconst client = new GotScrapingClient({ proxy: randomProxy })\n```\n\n### Using a custom User Agent\n\nIn a client that extends `BaseClient` we can also customize the `User-Agent` of the requests. We can do this in two ways:\n\n1. **By providing a `userAgent` string:\n\n```ts\nconst client = new GotScraingClient({ 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. **By providing a function that will generate a `userAgent`**:\n\n```ts\nfunction randomUserAgent() {\n    const userAgents = [\n        \"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\", \"Mozilla/5.0 (Windows NT 10.3;; en-US) AppleWebKit/537.35 (KHTML, like Gecko) Chrome/47.0.1707.185 Safari/601\"\n    ]\n\n    const randomIndex = Math.floor(Math.random() * userAgents.length)\n\n    return userAgents[randomIndex]\n}\n\nconst client = new GotScrapingClient({ userAgent: randomUserAgent })\n```\n\n### Using custom Proxy URL\n\nIn a client that extends `BaseClient` we can use proxy URLs, I don't know how to explain to you how they work, but I kind of discovered this kind of porxy when I was trying to solve the CORS problem by making a request on the client side, and then I met the *CORS Proxy*. Here I have a [template](https://gist.github.com/marcuth/9fbd321b011da44d1287faae31a8dd3a) for one for CloudFlare Workers in case you want to roll your own.\n\nWell, we can do it the same way we did with `userAgent`:\n\n1. **Providing a `proxyUrl` string**:\n\n```ts\nconst client = new GotScrapingClient({ proxyUrl: \"https://my-proxy-app.my-username.workers.dev\" })\n```\n\n2. **Providing a function that will generate a `proxyUrl`**:\n\n```ts\nfunction randomProxyUrl() {\n    const proxyUrls = [\n        \"https://my-proxy-app.my-username-1.workers.dev\",\n        \"https://my-proxy-app.my-username-2.workers.dev\"\n    ]\n\n    const randomIndex = Math.floor(Math.random() * proxyUrls.length)\n\n    return proxyUrls[randomIndex]\n}\n\nconst client = new GotScrapingClient({ proxyUrl: randomProxyUrl })\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## 📝 License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcrap-cloud%2Fgot-scraping-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxcrap-cloud%2Fgot-scraping-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcrap-cloud%2Fgot-scraping-client/lists"}