{"id":13539548,"url":"https://github.com/codemanki/cloudscraper","last_synced_at":"2025-04-02T06:31:06.114Z","repository":{"id":23933951,"uuid":"27315150","full_name":"codemanki/cloudscraper","owner":"codemanki","description":"--DEPRECATED -- 🛑 🛑 Node.js library to bypass cloudflare's anti-ddos page","archived":true,"fork":false,"pushed_at":"2020-05-09T16:20:23.000Z","size":850,"stargazers_count":604,"open_issues_count":19,"forks_count":141,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-03-14T17:17:07.632Z","etag":null,"topics":["cloudflare","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/codemanki.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-29T21:10:09.000Z","updated_at":"2025-03-13T19:38:54.000Z","dependencies_parsed_at":"2022-09-13T02:51:43.086Z","dependency_job_id":null,"html_url":"https://github.com/codemanki/cloudscraper","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemanki%2Fcloudscraper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemanki%2Fcloudscraper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemanki%2Fcloudscraper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemanki%2Fcloudscraper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemanki","download_url":"https://codeload.github.com/codemanki/cloudscraper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246767760,"owners_count":20830550,"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":["cloudflare","javascript"],"created_at":"2024-08-01T09:01:27.693Z","updated_at":"2025-04-02T06:31:01.104Z","avatar_url":"https://github.com/codemanki.png","language":"JavaScript","readme":"# 🛑 THIS LIBRARY IS NO LONGER SUPPORTED AND IS DEPRECATED 🛑\n\n\n\ncloudscraper\n============\n\nNode.js library to bypass Cloudflare's anti-ddos page.\n\n[![js-semistandard-style](https://cdn.rawgit.com/flet/semistandard/master/badge.svg)](https://github.com/Flet/semistandard)\n\n[![Build status](https://img.shields.io/travis/codemanki/cloudscraper/master.svg?style=flat-square)](https://travis-ci.org/codemanki/cloudscraper)\n[![Coverage](https://img.shields.io/coveralls/codemanki/cloudscraper.svg?style=flat-square)](https://coveralls.io/r/codemanki/cloudscraper)\n[![Dependency Status](https://img.shields.io/david/codemanki/cloudscraper.svg?style=flat-square)](https://david-dm.org/codemanki/cloudscraper)\n[![Greenkeeper badge](https://badges.greenkeeper.io/codemanki/cloudscraper.svg?style=flat-square)](https://greenkeeper.io/)\n\nIf the page you want to access is protected by Cloudflare, it will return special page, which expects client to support Javascript to solve challenge.\n\nThis small library encapsulates logic which extracts challenge, solves it, submits and returns the request page body.\n\nYou can use cloudscraper even if you are not sure if Cloudflare protection is turned on.\n\nIn general, Cloudflare has 4 types of _common_ anti-bot pages:\n  - Simple html+javascript page with challenge\n  - Page which redirects to original site\n  - Page with reCAPTCHA\n  - Page with error ( your ip was banned, etc)\n\nIf you notice that for some reason cloudscraper stops working, do not hesitate and get in touch with me ( by creating an issue [here](https://github.com/codemanki/cloudscraper/issues), for example), so i can update it.\n\nInstall\n============\n```sh\nnpm install cloudscraper\n```\n\nSaving the `request` module as a dependency is compulsory.\n\n```sh\n# Pin the request version\nnpm install --save request\n```\n\nSupport for Brotli encoded responses is enabled by default when using Node.js v10 or later.\nIf you wish to enable support for older Node.js versions, you may install [brotli](https://npmjs.com/package/brotli).\nIt is recommended but not required.\n\nUsage\n============\nCloudscraper uses `request-promise` by default since v3. You can find the migration guide [here.](docs/migration-guide.md)\n\n```javascript\nvar cloudscraper = require('cloudscraper');\n\ncloudscraper.get('https://website.com/').then(console.log, console.error);\n```\n\nor for `POST` action:\n\n```javascript\nvar options = {\n  uri: 'https://website.com/',\n  formData: { field1: 'value', field2: 2 }\n};\n\ncloudscraper.post(options).then(console.log).catch(console.error);\n```\n\n*Examples live in the docs directory of the Github repo and can be found [here.](docs/examples)*\n\nA generic request can be made with `cloudscraper(options)`. The options object should follow [request's options](https://www.npmjs.com/package/request#request-options-callback). Not everything is supported however, for example http methods other than GET and POST. If you wanted to request an image in binary data you could use the encoding option:\n\n```javascript\nvar options = {\n  method: 'GET',\n  url:'http://website.com/',\n};\n\ncloudscraper(options).then(console.log);\n```\n\n## Advanced usage\nCloudscraper allows you to specify your own requester, one of either `request` or `request-promise`.\nCloudscraper wraps the requester and accepts the same options, so using cloudscraper is pretty much like using those two libraries.\n - Cloudscraper exposes [the same HTTP verb methods as request](https://github.com/request/request#requestmethod):\n   * `cloudscraper.get(options, callback)`\n   * `cloudscraper.post(options, callback)`\n   * `cloudscraper(uri)`\n - Cloudscraper uses request-promise by default, promise chaining is done exactly the same as described in [docs](https://github.com/request/request-promise#cheat-sheet):\n ```\n  cloudscraper(options)\n    .then(function (htmlString) {\n    })\n    .catch(function (err) {\n    });\n  ```\nPlease refer to the requester's documentation for further instructions.\n\n## Sucuri\nCloudscraper can also identify and automatically bypass [Sucuri WAF](https://sucuri.net/website-firewall/). No actions are required.\n \n## ReCAPTCHA\nCloudscraper may help you with the reCAPTCHA page. Take a look at [this example](docs/examples/solve-recaptcha.js) and an [example using promises](docs/examples/solve-recaptcha-v2.js).\n\nCloudflare may send a reCAPTCHA depending on the negotiated TLS cipher suite and extensions. Reducing the default cipher suite to only ciphers supported by Cloudflare may mitigate the problem: https://developers.cloudflare.com/ssl/ssl-tls/cipher-suites/\n\nOnly specifying the Cloudflare preferred TLSv1.2 cipher is also an option:\n```javascript\nvar cloudscraper = require('cloudscraper').defaults({\n  agentOptions: {\n    ciphers: 'ECDHE-ECDSA-AES128-GCM-SHA256'\n  }\n})\n```\n\nMore information on TLS issues can be found [here](https://github.com/codemanki/cloudscraper/issues?utf8=%E2%9C%93\u0026q=tls).\n\n## Defaults method\n\n`cloudscraper.defaults` is a very convenient way of extending the cloudscraper requests with any of your settings.\n\n```javascript\nvar cloudscraper = require('cloudscraper').defaults({ 'proxy': 'http://localproxy.com' });\n// Overriding headers to remove them or using uncommon headers will cause reCAPTCHA responses\nvar headers = { /* ... */ };\nvar cloudscraper = require('cloudscraper').defaults({ headers: headers });\n\ncloudscraper(options).then(console.log);\n```\n\n## Configuration\nCloudscraper exposes the following options that are required by default but might be changed. *Please note that the default values eliminate the chance of getting sent a CAPTCHA.*\n\n```javascript\nvar options = {\n  uri: 'https://website',\n  jar: requestModule.jar(), // Custom cookie jar\n  headers: {\n    // User agent, Cache Control and Accept headers are required\n    // User agent is populated by a random UA.\n    'User-Agent': 'Ubuntu Chromium/34.0.1847.116 Chrome/34.0.1847.116 Safari/537.36',\n    'Cache-Control': 'private',\n    'Accept': 'application/xml,application/xhtml+xml,text/html;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5'\n  },\n  // Cloudscraper automatically parses out timeout required by Cloudflare.\n  // Override cloudflareTimeout to adjust it.\n  cloudflareTimeout: 5000,\n  // Reduce Cloudflare's timeout to cloudflareMaxTimeout if it is excessive\n  cloudflareMaxTimeout: 30000,\n  // followAllRedirects - follow non-GET HTTP 3xx responses as redirects\n  followAllRedirects: true,\n  // Support only this max challenges in row. If CF returns more, throw an error\n  challengesToSolve: 3,\n  // Remove Cloudflare's email protection, replace encoded email with decoded versions\n  decodeEmails: false,\n  // Support gzip encoded responses (Should be enabled unless using custom headers)\n  gzip: true,\n  // Removes a few problematic TLSv1.0 ciphers to avoid CAPTCHA\n  agentOptions: { ciphers }\n};\n\ncloudscraper(options).then(console.log);\n\n```\nYou can access the default configuration with `cloudscraper.defaultParams`\n\n## Error object\nCloudscraper error object inherits from `Error` has following fields:\n  * `name` - `RequestError`/`CaptchaError`/`CloudflareError`/`ParserError`\n  * `options` - The request options\n  * `cause` - An alias for `error`\n  * `response` - The request response\n  * `errorType` - Custom error code\nWhere `errorType` can be following:\n - `0` if request to page failed due to some native reason as bad url, http connection or so. `error` in this case will be error [event](http://nodejs.org/api/http.html#http_class_http_server)\n - `1` Cloudflare returned CAPTCHA. Nothing to do here. Bad luck\n - `2` Cloudflare returned page with some inner error. `error` will be `Number` within this range `1012, 1011, 1002, 1000, 1004, 1010, 1006, 1007, 1008`. See more [here](https://support.cloudflare.com/hc/en-us/sections/200820298-Error-Pages)\n - `3` this error is returned when library failed to parse and solve js challenge. `error` will be `String` with some details. :warning: :warning: __Most likely it means that Cloudflare have changed their js challenge.__\n - `4` CF went into a loop and started to return challenge after challenge. If number of solved challenges is greater than `3` and another challenge is returned, throw an error\n\nErrors are descriptive. You can find a list of all known errors [here.](errors.js)\n\n\nDo not always rely on `error.cause` to be an error, it can be a string.\n\nRunning tests\n============\nClone this repo, do `npm install` and then just `npm test`\n\n### Unknown error? Library stopped working? ###\nLet me know, by opening an [issue](https://github.com/codemanki/cloudscraper/issues) in this repo and I will update library asap. Please, provide url and body of page where cloudscraper failed.\n\nWAT\n===========\nCurrent Cloudflare implementation requires browser to respect the timeout of 5 seconds and cloudscraper mimics this behaviour. So everytime you call `cloudscraper.get/post` you should expect it to return result after minimum 6 seconds. If you want to change this behaviour, you would need to make a generic request as described in above and pass `cloudflareTimeout` options with your value. But be aware that Cloudflare might track this timeout and use it against you ;)\n\n## TODO\n - [x] Check for reCAPTCHA\n - [x] Support cookies, so challenge can be solved once per session\n - [x] Support page with simple redirects\n - [x] Add proper testing\n - [x] Remove manual 302 processing, replace with `followAllRedirects` param\n - [x] Parse out the timeout from challenge page\n - [x] Reorder the arguments in get/post/request methods and allow custom options to be passed in\n - [x] Support reCAPTCHA solving\n - [x] Promisification\n\n## Kudos to contributors\n - [Dwayne](https://github.com/pro-src)\n - [drdokk](https://github.com/drdokk)\n - [Cole Faust](https://github.com/Colecf)\n - [Jeongbong Seo](https://github.com/jngbng)\n - [Mike van Rossum](https://github.com/askmike)\n - [Santiago Castro](https://github.com/bryant1410)\n - [Leonardo Gatica](https://github.com/lgaticaq)\n - [Michael](https://github.com/roflmuffin)\n - [Kamikadze4GAME](https://github.com/Kamikadze4GAME)\n - [Anorov](https://github.com/Anorov) :star:\n\nIn the beginning cloudscraper was a port of python module [cloudflare-scrape](https://github.com/Anorov/cloudflare-scrape). Thank you [Anorov](https://github.com/Anorov) for an inspiration.\n\n## Dependencies\n* [request-promise](https://github.com/request/request-promise)\n","funding_links":[],"categories":["\u003ca id=\"1233584261c0cd5224b6e90a98cc9a94\"\u003e\u003c/a\u003e渗透\u0026\u0026offensive\u0026\u0026渗透框架\u0026\u0026后渗透框架","JavaScript","\u003ca id=\"5dd93fbc2f2ebc8d98672b2d95782af3\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"a0897294e74a0863ea8b83d11994fad6\"\u003e\u003c/a\u003eDDOS"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemanki%2Fcloudscraper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemanki%2Fcloudscraper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemanki%2Fcloudscraper/lists"}