Giter VIP home page Giter VIP logo

Comments (8)

thibauts avatar thibauts commented on September 25, 2024

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.

from node-google-search-scraper.

developeron29 avatar developeron29 commented on September 25, 2024

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)
});






from node-google-search-scraper.

thibauts avatar thibauts commented on September 25, 2024

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.

from node-google-search-scraper.

developeron29 avatar developeron29 commented on September 25, 2024

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.

from node-google-search-scraper.

developeron29 avatar developeron29 commented on September 25, 2024

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
localhost_4242_api_ _and_ayushnarula_ayushs-macbook-pro_ _-zsh_ _80x17_and_testsearch_js_ _state-of-mobile-web__drive-admin__developeron29_github_io

error_403__forbidden___1_ _and_index_html_ _state-of-mobile-web__drive-admin__developeron29_github_io

I'll update you, if i find a solution, Thanks!

from node-google-search-scraper.

DanDaDaDanDan avatar DanDaDaDanDan commented on September 25, 2024

Were you able to find a solution? Asking as I'm not having much luck with DBC as is.

from node-google-search-scraper.

edenfisher avatar edenfisher commented on September 25, 2024

any solution guys?

from node-google-search-scraper.

goldgavin avatar goldgavin commented on September 25, 2024

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})

from node-google-search-scraper.

Related Issues (16)

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.