Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-sr

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-sr - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

dist/index.d.ts

38

package.json
{
"name": "google-sr",
"version": "2.0.0",
"description": "Yet another library to do google searches, easy and simple",
"version": "3.0.0",
"description": "Fast and efficient Package for scraping Google search results without the need for an API key",
"repository": "typicalninja493/google-sr",
"main": "index.js",
"types": "index.d.ts",
"dependencies": {
"axios": "^0.26.0",
"cheerio": "^1.0.0-rc.10"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"homepage": "https://typicalninja493.github.io/google-sr/",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"keywords": [

@@ -23,3 +17,21 @@ "google-sr",

"author": "typicalninja493",
"license": "MIT"
}
"license": "Apache-2.0",
"dependencies": {
"axios": "^1.4.0",
"cheerio": "1.0.0-rc.12",
"deepmerge-ts": "^5.1.0"
},
"devDependencies": {
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"chai": "^4.3.7",
"mocha": "^10.2.0",
"ts-node": "^10.9.1",
"tsup": "^7.2.0",
"typescript": "^5.1.6"
},
"scripts": {
"test": "mocha --require ts-node/register tests/*.ts",
"build": "tsup"
}
}

@@ -1,66 +0,91 @@

## Google-sr
# google-sr 🔍
Yet another library to do google searches.
Fast and efficient Package for scraping Google search results without the need for an API key. 🚀
Below is a simple example of using this package
> View documentation [here](https://typicalninja493.github.io/google-sr/)
## Install
## Features ✨
```
* Lightweight 💨
* Fast and efficient ⚡️ *
* Well tested 🔄
* TypeScript compatible 🧑‍💻
> \* depends on amount of pages fetched (avg of 1s per page in testing)
## Install 📦
To get started, you can install **google-sr** using your preferred package manager:
```bash
# npm
npm install google-sr
```
* Typescript and Javascript compatible
# pnpm
## Usage
pnpm add google-sr
#### with `.then`
##### Without safe mode
```ts
import search from 'google-sr'
# yarn
search('node.js', { safeMode: false }).then(r => console.log(r))
yarn add google-sr
```
##### With safe mode
# Usage
### Simple example
You can easily perform a single-page search like this:
```ts
import search from 'google-sr'
import { search } from 'google-sr';
search('node.js').then(r => console.log(r))
search({ query: 'nodejs' }).then(console.log);
// or if using await/async
const searchResults = await search({ query: 'nodejs' });
console.log(searchResults);
```
### With async/await
> More detailed examples & usage can be found [here](https://typicalninja493.github.io/google-sr#usage)
```ts
import search from 'google-sr'
// use an iife to use await
(async () => {
const result = await search('node.js')
console.log(result)
// search('node.js', { safeMode: false }) for without safe mode
})()
```
## Important Notes 🚨
### Available options
* google-sr scrapes the HTML of Google search results. This means it relies on Google's predefined HTML structure. If Google changes this structure, the package might seem to behave unexpectedly. To avoid this, it's best to keep your package updated to the latest version. (Note: we may take time to update it to any new structure)
* Page - default:- **1**
* Selectors - {
`DescriptionSelector`,
`linkSelector`,
`TitleSelector`
} - default: `DefaultSelectors`
* safeMode - default :- `true`
selectors default -
* DescriptionSelector - `#main > div > div > div > div:not(.v9i61e) > div.AP7Wnd`
* linkSelector - `div.ZINbbc > div:nth-child(1) > a`
* TitleSelector - `div.ZINbbc > div:nth-child(1) > a > h3`
> View current selectors [here](https://typicalninja493.github.io/google-sr/selectors)
# Support
* Fetching multiple pages can be slow, we recommended either fetching only small amount (i.e 5 max) or fetching pages in chunks as needed using specific page control of `searchWithPages` function
Join my discord server for support: [discord](https://discord.gg/9s52pz6nWX)
# Tests
Tests are written using [mocha](https://mochajs.org/) and can be run by using the `test` script
```bash
# npm
npm run test
# pnpm
pnpm run test
# yarn
yarn run test
```
# Support & Bug Reporting 🛠️🐞
> Make sure you are on the latest version before creating bug reports
Support and bug reporting both can be done on either my [discord server](https://discord.gg/9s52pz6nWX) or on [github issues](https://github.com/typicalninja493/google-sr/issues)
# License
This repository and the code inside it is licensed under the MIT License. Read [LICENSE](https://github.com/typicalninja493/google-sr/blob/master/LICENSE) for more information.
This repository and the code inside it is licensed under the Apache-2.0 License. Read [LICENSE](./LICENSE) for more information.

Sorry, the diff of this file is not supported yet

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