Scrape google-sr search results without an API key with javascript/typescript.
google-sr
does not support web environments, but it has been tested and confirmed to work on the following runtimes:
- Node.js
- Bun
- Deno (with the
npm:
specifier)
To get started, you can install google-sr using your preferred package manager:
npm install google-sr
# For pnpm/yarn/bun:
pnpm/yarn/bun add google-sr
# For Deno, either use the npm: specifier
# or import from esm.sh
# https://esm.sh/google-sr
This example demonstrates some of the features of google-sr
. For a bare minimum setup, refer to the examples/basic file.
import {
search,
OrganicResult, // Import the result types you need
DictionaryResult,
ResultTypes, // Import to filter results by type
} from "google-sr";
const queryResult = await search({
query: "nodejs",
// Specify the result types explicitly ([OrganicResult] is the default, but it is recommended to always specify the result type)
resultTypes: [OrganicResult, DictionaryResult],
// Optional: Customize the request using AxiosRequestConfig (e.g., enabling safe search)
requestConfig: {
params: {
safe: "active", // Enable "safe mode"
},
},
});
// will return a SearchResult[]
console.log(queryResult);
console.log(queryResult[0].type === ResultTypes.OrganicResult); // true
Note: By default, only results of type
ResultTypes.OrganicResult
are returned. Use theresultTypes
option to customize the output.
- Additional examples can be found in apps/examples directory
Please refer to the google-sr API 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.
This is not sponsored, supported, or affiliated with Google.
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 its use, such as IP blocking by Google. Your discretion in usage is advised.
GSR project has a mirror repository on codeberg You can find it here
- All issues and discussion are limited to github & discord
Tests are written using vitest and can be run by using the test
script.
Weekly tests are executed using a github action to ensure compatibility and catch breakage due to google changes
pnpm run test
This repository and the code inside it is licensed under the Apache-2.0 License. Read LICENSE for more information.