Easy to use, updated tools for scraping google search results. π
To get started, you can install google-sr using your preferred package manager:
# npm
npm install google-sr
# pnpm
pnpm add google-sr
# yarn
yarn add google-sr
You can easily perform a single-page search like this:
import { search, OrganicResult } from 'google-sr';
// using await/async
const queryResult = await search({
query: "nodejs",
// OrganicResult is the default, however it is recommended to always specify the result type
resultTypes: [OrganicResult],
});
// will return a SearchResult[]
console.log(queryResult);
// should log: true
console.log(queryResult[0].type === ResultTypes.OrganicResult)
To search for multiple pages of results, use the searchWithPages
function:
import { searchWithPages, OrganicResult } from 'google-sr';
// using await/async
const queryResult = await searchWithPages({
query: "nodejs",
// OrganicResult is the default, however it is recommended to always specify the result type
resultTypes: [OrganicResult],
pages: 2,
});
// will return a SearchResult[][]
console.log(queryResult);
// should log: true
console.log(queryResult[0][0].type === ResultTypes.OrganicResult)
By default only
ResultTypes.OrganicResult
result type are returned, use the resultTypes option to configure it
- Additional examples can be found in tests and apps/examples directory
Please refer to the google-sr readme in packages/google-sr
Welcome to the π¦ monorepo of GSR Project.
π This is the home to google-sr and its related packages & applications.
This monorepo is managed with turborepo and uses pnpm workspaces.
GSR project has a mirror repository on codeberg You can find it here
- All issues and discussion are limited to github & discord
This is not sponsored, supported, or affiliated with Google Inc.
Unlike the conventional recommendation of using the Google API, this module scrapes the Google search result page (which might potentially infringe upon Google's terms of service).
The source code within this repository is intended solely for educational & research purposes.
The author (typicalninja) & contributors takes NO responsibility for any issues that arise from misuse, such as IP blocking by Google. Your discretion in usage is advised.
This repository and the code inside it is licensed under the Apache-2.0 License. Read LICENSE for more information.