# captcha-solver

> Library for automating captcha verification.

[![NPM](https://img.shields.io/npm/v/captcha-solver.svg)](https://www.npmjs.com/package/captcha-solver) [![Build Status](https://travis-ci.com/transitive-bullshit/captcha-solver.svg?branch=master)](https://travis-ci.com/transitive-bullshit/captcha-solver) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

<p align="center">
  <img width="313" alt="Nocaptcha Recaptcha" src="https://cdn.rawgit.com/transitive-bullshit/captcha-solver/master/packages/captcha-solver/media/nocaptcha.gif">
</p>

This module also has a [CLI](https://github.com/transitive-bullshit/captcha-solver/tree/master/packages/captcha-solver-cli).

## Install

This module requires `node >= 8`.

```bash
npm install --save captcha-solver
```

## Usage

```js
const CaptchaSolver = require('captcha-solver')

const solver = new CaptchaSolver('browser')
const codes = await solver.solve()
```

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

-   [CaptchaSolver](#captchasolver)
    -   [provider](#provider)
    -   [createTask](#createtask)
    -   [getTaskResult](#gettaskresult)

### [CaptchaSolver](https://github.com/transitive-bullshit/captcha-solver/blob/ec5e0649a40d0489264905d80a991f071703fce2/packages/captcha-solver/index.js#L19-L128)

Main entrypoint for solving captchas.

Type: `function (provider, opts)`

-   `provider` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | CaptchaSolverProvider)** Name of built-in provider or an instance of
    a custom provider to use for solving.
-   `opts`   (optional, default `{}`)

* * *

#### [provider](https://github.com/transitive-bullshit/captcha-solver/blob/ec5e0649a40d0489264905d80a991f071703fce2/packages/captcha-solver/index.js#L33-L33)

Provider powering this solver.

Type: CaptchaSolverProvider

* * *

#### [createTask](https://github.com/transitive-bullshit/captcha-solver/blob/ec5e0649a40d0489264905d80a991f071703fce2/packages/captcha-solver/index.js#L70-L92)

Creates a new captcha solving task.

Valid values for `opts.type` are:

-   image-to-text
-   recaptcha
-   recaptcha-proxyless
-   nocaptcha
-   nocaptcha-proxyless
-   funcaptcha
-   funcaptcha-proxyless

Note that not all providers support all captcha types. See
`provider.supportedTaskTypes` for a Set containing all task types a given
provider supports.

Note that most of these options will be unused depending on the task type.

Type: `function (opts)`

-   `opts` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Options
    -   `opts.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of captcha to solve
    -   `opts.image` **([buffer](https://nodejs.org/api/buffer.html) \| [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))?** Path, URL, or buffer of an image to process
    -   `opts.websiteURL` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Website URL for nocaptcha, recaptcha, and funcaptcha
    -   `opts.websiteKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Recaptcha website key
    -   `opts.websiteSToken` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Secret token for old versions of Recaptcha
    -   `opts.websitePublicKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Funcaptcha public key
    -   `opts.proxyType` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Proxy type (http/socks4/socks5)
    -   `opts.proxyAddress` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Proxy IP address (ipv4/ipv6)
    -   `opts.proxyPort` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number))?** Proxy port
    -   `opts.proxyLogin` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Proxy login for basic auth
    -   `opts.proxyPassword` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Proxy password
    -   `opts.userAgent` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Browser's User-Agent to emulate
    -   `opts.cookies` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Additional cookies to emulate

* * *

#### [getTaskResult](https://github.com/transitive-bullshit/captcha-solver/blob/ec5e0649a40d0489264905d80a991f071703fce2/packages/captcha-solver/index.js#L104-L127)

Fetches the result of a previously created captcha solving task.

Type: `function (taskId, opts)`

-   `taskId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Unique task identifier
-   `opts` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Options (optional, default `{}`)
    -   `opts.retries` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number of retries to perform (optional, default `3`)
    -   `opts.timeout` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Max timeout to wait in ms before aborting (optional, default `30000`)

* * *

## Related

-   [captcha-solver-cli](https://github.com/transitive-bullshit/captcha-solver/tree/master/packages/captcha-solver-cli) - CLI for this module.
-   [puppeteer-email](https://github.com/transitive-bullshit/puppeteer-email) - Email automation driven by headless chrome.
-   [sms-number-verifier](https://github.com/transitive-bullshit/sms-number-verifier) - Allows you to spoof SMS number verification.
-   [awesome-puppeteer](https://github.com/transitive-bullshit/awesome-puppeteer) - A curated list of awesome puppeteer resources.

## Disclaimer

Using this software to violate the terms and conditions of any third-party service is strictly against the intent of this software. By using this software, you are acknowledging this fact and absolving the author or any potential liability or wrongdoing it may cause. This software is meant for testing and experimental purposes only, so please act responsibly.

## License

MIT © [Travis Fischer](https://github.com/transitive-bullshit)
