Code Monkey home page Code Monkey logo

deathbycaptcha.js's Introduction

DeathByCaptcha.js v0.0.3

Node.js client library for the DeathByCaptcha service.

Installation

DeathByCaptcha.js is available in npm.

npm install deathbycaptcha

Usage

Using the API goes a little something like this:

DeathByCaptcha = require("deathbycaptcha");
var dbc = new DeathByCaptcha("your_dbc_user", "your_dbc_pass");

dbc.solve(fs.readFileSync("/your/captcha/file"), function(err, id, solution) {
	if(err) return console.error(err); // onoes!

	if(solution !== "moo") {
		// It was wrong!
		dbc.report(id, function(err) {
			if(err) return console.error(err); // ONOES!
		});
	}
});

Solve CAPTCHA

Send a CAPTCHA image file to DeathByCaptcha to solve.

DeathByCaptcha.solve(captchaImage, callback);

Callback accepts three parameters:

  • error: if something went wrong sending or solving the CAPTCHA.
  • captchaId: the ID of the CAPTCHA.
  • solution: the solution to the CAPTCHA, as text.

Example:

dbc.solve(fs.readFileSync("/your/captcha/file"), function(err, id, solution) {
	if(err) return console.error(err);
	console.log("CAPTCHA solution is", solution);
});

Get CAPTCHA

Gets a previously solved (or in progress) CAPTCHA by ID. If the CAPTCHA is still in progress the callback will wait for it.

DeathByCaptcha.get(captchaId, callback);

Callback takes 3 arguments:

  • error: if something went wrong.
  • solution: the solution for the CAPTCHA.
  • isCorrect: true/false if the CAPTCHA is "correct" (hasn't beenr reported)

Example:

dbc.get(12345, function(err, solution, isCorrect) {
	if(err) return console.error(err);
	// isComplete is false if the CAPTCHA has been reported (see below).
	console.log("Captcha solution is", solution);
	console.log("Is it correct?", isCorrect);
});

Report CAPTCHA

Use this if you have reason to believe DeathByCaptcha incorrectly solved your CAPTCHA image.

DeathByCaptcha.report(captchaId, callback);

Callback will be handed an error if something went wrong, else nothing will be passed.

Example:

dbc.report(12345, function(err) {
	if(err) return console.error(err);
	console.log("CAPTCHA was reported successfully.")
	console.log("If it wasn't older than an hour, it should have refunded");
});

Get Balance

Loads balance stats for your account from DeathByCaptcha.

DeathByCaptcha.balance(callback);

Callback:

  • error: if something went wrong
  • credits: computed number of CAPTCHA solutions remaining.
  • balance: balance in US cents.
  • rate: cost per solution in US cents.

Example:

dbc.balance(function(err, credits, balance, rate) {
	if(err) return console.error(err);
	console.log(credits + " credits remaining");
	console.log("($" + (balance / 100) + " @ " + rate + "c/solution");
});

Fineprint

deathbycaptcha.js is Copyright (c) 2012 Sam Day

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

See COPYING for more information.

deathbycaptcha.js's People

Contributors

eugeneware avatar

Stargazers

Rodrigo Orem avatar Kiver Teixeira avatar luigi avatar Brad avatar Anton Stoychev avatar  avatar Sam avatar

Watchers

Brad avatar Sam avatar James Cloos avatar  avatar

Forkers

rodorgas

deathbycaptcha.js's Issues

Unexpected error

error: Unexpected error.
    at Request._callback (/***/node_modules/deathbycaptcha/deathbycaptcha.js:98:23)
    at Request.self.callback (/***/node_modules/deathbycaptcha/node_modules/request/index.js:148:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/***/node_modules/deathbycaptcha/node_modules/request/index.js:876:14)
    at emitOne (events.js:101:20)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/***/node_modules/deathbycaptcha/node_modules/request/index.js:827:12)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:926:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

Node: v6.2.1
deathbycaptcha: v0.0.3

403 (Invalid Login / Insufficient Credits)

I've used this module in the past and had no issues, but the exact same code seems to be failing now. I can still log in to DBC and check my balance, but when an image is submitted (only tested by stream), the response is always a 403 Forbidden. I've taken the issue up with support, and they said it's not an issue on their end (still skeptical about that). I tested with the command line tool they provide, and it seems to work fine.

I'm not sure if something changed in the past month or two in their API, but from reading the docs it seems like it should work. Below is a captured POST request for reference.

{
    url: 'http://api.dbcapi.me/api/captcha',
    headers: {
        'content-type': 'multipart/form-data'
    },
    multipart: [  
        {
            'content-disposition': 'form-data; name="captchafile"; filename="captcha"',
            'content-type': 'application/octet-stream',
             body: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 d3 00 00 00 28 08 02 00 00 00 eb 30 58 54 00 00 18 c1 49 44 41 54 78 9c ed 9c 57 7b 1b 57 9a e7 ...>
        },
        {
            'content-disposition': 'form-data; name="username"',
            body: 'REDACTED'
        },
        {
            'content-disposition': 'form-data; name="password"',
            body: 'REDACTED'
        }
    ]  
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.