google-sr - v3.2.1
Table of contents
Enumerations
Interfaces
- CurrencyResultNode
- DictionaryResultNode
- SearchOptions
- SearchResultNode
- TimeResultNode
- TranslateResultNode
Type Aliases
Functions
- generateArrayOfNumbers
- loadCurrencyNode
- loadDictionaryNodes
- loadSearchNodes
- loadTimeNode
- loadTranslateNodes
- pageToGoogleQueryPage
- search
- searchWithPages
Type Aliases
ResultNode
Ƭ ResultNode: SearchResultNode
| TranslateResultNode
| DictionaryResultNode
| TimeResultNode
| CurrencyResultNode
Defined in
google-sr/src/constants.ts:100
Functions
generateArrayOfNumbers
▸ generateArrayOfNumbers(maxNumber
): number
[]
Parameters
Name | Type |
---|---|
maxNumber | number |
Returns
number
[]
Defined in
loadCurrencyNode
▸ Private
loadCurrencyNode($
, selectors
): CurrencyResultNode
| null
Parameters
Name | Type |
---|---|
$ | CheerioAPI |
selectors | Object |
selectors.from | string |
selectors.to | string |
Returns
CurrencyResultNode
| null
Defined in
loadDictionaryNodes
▸ Private
loadDictionaryNodes($
, selectors
): DictionaryResultNode
| null
Loader for dictionary blocks
Parameters
Name | Type |
---|---|
$ | CheerioAPI |
selectors | Object |
selectors.audio | string |
selectors.definitions | string |
selectors.examples | string |
selectors.phonetic | string |
selectors.word | string |
Returns
DictionaryResultNode
| null
Defined in
loadSearchNodes
▸ Private
loadSearchNodes($
, selectors
): SearchResultNode
[]
Loader for Regular Results
Parameters
Name | Type |
---|---|
$ | CheerioAPI |
selectors | Object |
selectors.block | string |
selectors.description | string |
selectors.link | string |
selectors.title | string |
Returns
Defined in
loadTimeNode
▸ Private
loadTimeNode($
, selectors
): TimeResultNode
| null
Parameters
Name | Type |
---|---|
$ | CheerioAPI |
selectors | Object |
selectors.location | string |
selectors.time | string |
selectors.timeInWords | string |
Returns
TimeResultNode
| null
Defined in
loadTranslateNodes
▸ Private
loadTranslateNodes($
, selectors
): TranslateResultNode
| null
Loader for translation blocks
Parameters
Name | Type |
---|---|
$ | CheerioAPI |
selectors | Object |
selectors.pronunciation | string |
selectors.sourceLanguage | string |
selectors.sourceText | string |
selectors.targetLanguage | string |
selectors.translationText | string |
Returns
TranslateResultNode
| null
Defined in
pageToGoogleQueryPage
▸ pageToGoogleQueryPage(page
): number
Convert a normal page to google query page
Parameters
Name | Type |
---|---|
page | number |
Returns
number
Defined in
search
▸ search(searchOptions
): Promise
<ResultNode
[]>
Search for a individual page
Parameters
Name | Type |
---|---|
searchOptions | Partial <SearchOptions > |
Returns
Promise
<ResultNode
[]>
Array of Results
Example
search({ query: 'nodejs' }).then(console.log);
// or if using await/async
const searchResults = await search({ query: 'nodejs' });
console.log(searchResults);
Defined in
searchWithPages
▸ searchWithPages(«destructured»
): Promise
<ResultNode
[][]>
Search multiple pages
Parameters
Name | Type |
---|---|
«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
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
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);