Open developeron29 opened 8 years ago
Your customsolver should take imageData
and return the text contained in the captcha image. I don't understand what your are doing with your API endpoint.
Yep, Absolutely, Right
That's what i'm trying to do, by rendering the image to the browser, entering the text into the input box and sending it to the captcha solver
Thanks for the help!
The whole code:
var scraper = require('google-search-scraper');
var application_root = __dirname,path = require("path");
//var DeathByCaptcha = require('deathbycaptcha');
var http = require('http')
, fs = require('fs');
var express = require('express'); // call express
var app = express.createServer(); // set our port
app.configure(function () {
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(application_root, "public")));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
//var dbc = new DeathByCaptcha('username', 'password');
var customSolver = {
solve: function(imageData, callback) {
// Do something with image data, like displaying it to the user
// id is used by BDC to allow reporting solving errors and can be safely ignored here
console.log(imageData);
//var router = express.Router(); // get an instance of the express Router
// if (err) throw err; // Fail if the file can't be read.
app.get('/api', function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<html><body><img src="data:image/jpeg;base64,')
res.write(new Buffer(imageData).toString('base64'));
res.write('"/>');
res.write('<form method="post" action="/api/bears/">');
res.write('<input type="text" name="user[name]">');
res.write('<input type="submit" value="Submit">');
res.write('</form>');
res.end('</body></html>');
});
app.post('/api/bears', function(req, res) {
console.log(req.body.user.name);
var id = null, err = null;
callback(err, id, req.body.user.name);
res.end();
});
}
};
app.listen(4242);
var options = {
query: 'site:edu "information theory"',
age: 'y', // less than a year,
solver: customSolver
};
scraper.search(options, function(err, url) {
// This is called for each result
if(err) throw err;
console.log(url)
});
If your code correctly returns the right decoded text to the callback then google probably changed its way to handle the captcha solution submission. It's very unexpected as seemingly the first part doesn't change, or your code wouldn't display a correct image.
If you want to make it work you'll have to investigate by navigating to google in your browser, solving the captcha by hand, looking at the form submission in the traffic and modifying the code so it behaves in the same way.
Great, Thanks! I might have found the problem: On doing the search on browser instead, google was returning two captchas one after the other So, after getting the first one correct, it shows one more captcha.
Yes, After returning the captcha text, maybe Google recognizes that the user is unauthorized to access the page and i get this html: , with statusCode 403
I'll update you, if i find a solution, Thanks!
Were you able to find a solution? Asking as I'm not having much luck with DBC as is.
any solution guys?
captchaId changed, use post instead of get, then it will return redirect url then get it again
var captchaId = $('input[name=q]').attr('value');
session.post({
uri: baseUrl + '/sorry/' + formAction,
qs: {
q: captchaId,
captcha: solution,
continue: continueUrl
}
}, function(err, res) { // get the res.headers.location if statusCode is 302})
customSolver not working
On creating a server and sending the image to the browser and later posting the result to be sent through the callback returns
with customSolver as