New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gsearch-node

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gsearch-node

API for making google search requests with captcha support

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by57.14%
Maintainers
1
Weekly downloads
 
Created
Source

gsearch-node

API for making google search requests with captcha support
Installation
`npm install -S gsearch-node`
API explained
-
Initailization (with deathbycaptcha as captcha solver)
````javascript var deathByCaptcha = require("deathbycaptcha") var dbc = new deathByCaptcha("username", "password")

var gsearch = require("gsearch-node") var gs = new gsearch({solver: dbc})


- <h5>Initailization (with custom solver)</h5>
````javascript
var captchaSolver = {
   solve: function (img, cb) {
      //doSomeCaptchaSolving
      if (err) {
         cb (null, {
            err: err,
            solution: null
         })
         return
      }
      
      cb (null, {
         err: null,
         solution: "solved captcha as string"
      })
   }
}
  • API methods
    - `gs.get(searchString, cb)`
    This is an async function which returns a `cb` with `(nullVar, respObj)`.
    `nullVar` is a variable with `null` value.
    `respObj` is an object with following structure :- ````javascript respObj = { err: null, resp: {}, // a response object from request library. use respObj.resp.body to get the html. parsed: {} // parsed html using whacko lib (a fork of cheerio). // so you can apply css selectors directly. } ````
    • gs.getSync(seachString)
      This is a sync function which returns 'respObj' as described above.
  • Note on callbacks
    The format of callbacks for this API is *not* `(err, resp)` but is `(nullVar, respObj)` where `err` is a property of `respObj`.
    This is because I have used deasync lib which throws `err` if `(err, resp)` format is used for the callback which make the code to break. Error handling is more easier as we can use `if` syntax instead of `try catch`.
Test/Usage
````javascript (function () {

// var deathByCaptcha = require("deathbycaptcha") // var dbc = new deathByCaptcha("username", "password")

var gsearch = require("gsearch-node") var gs = new gsearch({solver: {}}) // {solver: dbc} for using deathbycaptcha api

console.log("Sync version") var searchPage = gs.getSync("Everyone shifting to nodejs?") if (!searchPage.err) { $ = searchPage.parsed $("a").each(function (i, a) { console.log($(a).attr("href")) }) } else { console.log(searchPage.err) }

console.log("\nAsync version") gs.get("Everyone shifting to nodejs?", function (nullVar, searchPage) { if (!searchPage.err) { $ = searchPage.parsed $("a").each(function (i, a) { console.log($(a).attr("href")) }) } else { console.log(searchPage.err) }
})

})()


<h4>Donate</h4>
<p>If this repository helps you anyhow, please don't mind coming back and 
   <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=F3QQCWFPWHBYE" target="_blank">Buy Me Coffee</a>
OR you can use 
   <a href="https://gratipay.com/~xcelancer/" target="_blank">Gratipay</a>
to show your appreciation and gratitude.
</p>

Keywords

FAQs

Package last updated on 26 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc