# gsearch-node

> API for making google search requests with captcha support

Latest version **0.0.8** (published 2017-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install gsearch-node
pnpm add gsearch-node
yarn add gsearch-node
bun add gsearch-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2017-03-30 |
| First published | 2016-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vikas Gautam |
| Maintainers | vikasg7 |
| Keywords | google, search, captcha, deathbycaptcha, api, nodejs, npm, google captcha solver |

## Links

- npm: https://www.npmjs.com/package/gsearch-node
- Repository: https://github.com/Vikasg7/gsearch
- Homepage: https://github.com/Vikasg7/gsearch#readme
- Issues: https://github.com/Vikasg7/gsearch/issues
- npm.io page: https://npm.io/package/gsearch-node

## Dependencies (4)

- [whacko](https://npm.io/package/whacko.md) latest
- [deasync](https://npm.io/package/deasync.md) latest
- [decache](https://npm.io/package/decache.md) latest
- [request](https://npm.io/package/request.md) latest

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.0.8 (latest) — 2017-03-30
- 0.0.7 — 2017-03-23
- 0.0.6 — 2017-02-09
- 0.0.5 — 2017-02-01
- 0.0.4 — 2017-01-26
- 0.0.3 — 2016-09-20
- 0.0.2 — 2016-08-15
- 0.0.1 — 2016-08-15

## README

<h1>gsearch-node</h1>
<h5>API for making google search requests with captcha support</h5>

<h4>Installation</h4>
`npm install -S gsearch-node`

<h4>API explained</h4>
- 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})
   ```

- Initailization (with custom solver)  
   
   ```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)`<br>
      This is an async function which returns a `cb` with `(nullVar, respObj)`.<br>
      `nullVar` is a variable with `null` value.<br>
      `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)`<br>
      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`.<br>
   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.<r>
   Error handling is more easier as we can use `if` syntax instead of `try catch`. 

<h4>Test/Usage</h4>  

```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>

---
_Source: https://npm.io/package/gsearch-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
