Scrape Google search results using JavaScript / TypeScript
Not supported in browser environments.
npm install google-sr
# For pnpm/yarn/bun:
pnpm add google-sr
yarn add google-sr
bun add google-sr
import {
search,
OrganicResult,
TranslateResult,
ResultTypes,
} from "google-sr";
const results = await search({
query: "translate hello to japanese",
// Explicitly specify the results you want
resultTypes: [TranslateResult, OrganicResult],
});
console.log(results[0].type === ResultTypes.TranslateResult); // true
console.log(results) // see below
[
{
// type property is present in all results
type: 'TRANSLATE',
sourceLanguage: 'English (detected)',
translationLanguage: 'Japanese',
sourceText: 'hello',
translatedText: 'こんにちは'
},
{
type: 'ORGANIC',
link: '...',
description: "Konnichiwa – ...",
title: '18 ...'
},
// ... and more
]
Additional examples can be found in apps/examples directory
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. Your discretion in usage is advised.
Tests are written using vitest and can be run by using the test
script.
pnpm run test
This repository and the code inside it is licensed under the Apache-2.0 License. Read LICENSE for more information.
Want to support the project? Star it on GitHub ★