Skip to content

google-sr - v3.2.1

Table of contents

Enumerations

Interfaces

Type Aliases

Functions

Type Aliases

ResultNode

Ƭ ResultNode: SearchResultNode | TranslateResultNode | DictionaryResultNode | TimeResultNode | CurrencyResultNode

Defined in

google-sr/src/constants.ts:100

Functions

generateArrayOfNumbers

generateArrayOfNumbers(maxNumber): number[]

Parameters

NameType
maxNumbernumber

Returns

number[]

Defined in

google-sr/src/helpers.ts:83


loadCurrencyNode

Private loadCurrencyNode($, selectors): CurrencyResultNode | null

Parameters

NameType
$CheerioAPI
selectorsObject
selectors.fromstring
selectors.tostring

Returns

CurrencyResultNode | null

Defined in

google-sr/src/loaders.ts:170


loadDictionaryNodes

Private loadDictionaryNodes($, selectors): DictionaryResultNode | null

Loader for dictionary blocks

Parameters

NameType
$CheerioAPI
selectorsObject
selectors.audiostring
selectors.definitionsstring
selectors.examplesstring
selectors.phoneticstring
selectors.wordstring

Returns

DictionaryResultNode | null

Defined in

google-sr/src/loaders.ts:96


loadSearchNodes

Private loadSearchNodes($, selectors): SearchResultNode[]

Loader for Regular Results

Parameters

NameType
$CheerioAPI
selectorsObject
selectors.blockstring
selectors.descriptionstring
selectors.linkstring
selectors.titlestring

Returns

SearchResultNode[]

Defined in

google-sr/src/loaders.ts:25


loadTimeNode

Private loadTimeNode($, selectors): TimeResultNode | null

Parameters

NameType
$CheerioAPI
selectorsObject
selectors.locationstring
selectors.timestring
selectors.timeInWordsstring

Returns

TimeResultNode | null

Defined in

google-sr/src/loaders.ts:143


loadTranslateNodes

Private loadTranslateNodes($, selectors): TranslateResultNode | null

Loader for translation blocks

Parameters

NameType
$CheerioAPI
selectorsObject
selectors.pronunciationstring
selectors.sourceLanguagestring
selectors.sourceTextstring
selectors.targetLanguagestring
selectors.translationTextstring

Returns

TranslateResultNode | null

Defined in

google-sr/src/loaders.ts:56


pageToGoogleQueryPage

pageToGoogleQueryPage(page): number

Convert a normal page to google query page

Parameters

NameType
pagenumber

Returns

number

Defined in

google-sr/src/helpers.ts:79


search(searchOptions): Promise<ResultNode[]>

Search for a individual page

Parameters

NameType
searchOptionsPartial<SearchOptions>

Returns

Promise<ResultNode[]>

Array of Results

Example

ts
search({ query: 'nodejs' }).then(console.log);
// or if using await/async
const searchResults = await search({ query: 'nodejs' });
console.log(searchResults);

Defined in

google-sr/src/search.ts:37


searchWithPages

searchWithPages(«destructured»): Promise<ResultNode[][]>

Search multiple pages

Parameters

NameType
«destructured»Partial<Omit<SearchOptions, "page">> & { pages: number | number[] }

Returns

Promise<ResultNode[][]>

Array of arrays representing pages containing search results

Example

Specify amount of pages to fetch

ts

searchWithPages({ query: 'nodejs', pages: 5 }).then(console.log);
// or if using await/async
const searchResults = await searchWithPages({ query: 'nodejs', pages: 5 });
console.log(searchResults);

Example

Specifying specific pages to fetch

ts
searchWithPages({ query: 'nodejs', pages: [1, 2, 5, 10] }).then(console.log);
// or if using await/async
const searchResults = await searchWithPages({ query: 'nodejs', pages: [1, 2, 5, 10] });
console.log(searchResults);

Defined in

google-sr/src/search.ts:120