google-sr
Advanced tools
Comparing version 3.2.1 to 3.3.0
@@ -156,5 +156,5 @@ import { AxiosRequestConfig } from 'axios'; | ||
* Search multiple pages | ||
* @param query | ||
* @param pages no of pages or array of pages numbers to retrieve | ||
* @param options | ||
* @param options.pages no of pages / array of pages numbers to retrieve | ||
* @param options.searchDelay amount of milliseconds (ms) the package should wait between retrieving results (default is disabled) useful with ratelimits | ||
* @returns Array of arrays representing pages containing search results | ||
@@ -183,4 +183,5 @@ * | ||
*/ | ||
declare function searchWithPages({ pages, ...options }: Partial<Omit<SearchOptions, "page">> & { | ||
declare function searchWithPages({ pages, searchDelay, ...options }: Partial<Omit<SearchOptions, "page">> & { | ||
pages: number | number[]; | ||
searchDelay?: number; | ||
}): Promise<ResultNode[][]>; | ||
@@ -187,0 +188,0 @@ |
@@ -118,2 +118,3 @@ "use strict"; | ||
var generateArrayOfNumbers = /* @__PURE__ */ __name((maxNumber) => new Array(maxNumber).fill(0).map((_, index) => index + 1), "generateArrayOfNumbers"); | ||
var sleep = /* @__PURE__ */ __name((ms) => new Promise((resolve) => setTimeout(resolve, ms)), "sleep"); | ||
@@ -177,3 +178,3 @@ // src/search.ts | ||
const definitions = []; | ||
$("div.v9i61e > div.BNeawe.s3v9rd.AP7Wnd:not(:has(span.r0bn4c.rQMQod))").each( | ||
$(selectors2.definitions).each( | ||
(index, el) => { | ||
@@ -184,3 +185,3 @@ definitions[index] = ["", ""]; | ||
); | ||
$("div.v9i61e > div.BNeawe > span.r0bn4c.rQMQod").each((index, el) => { | ||
$(selectors2.examples).each((index, el) => { | ||
if (definitions[index]) { | ||
@@ -280,2 +281,3 @@ let example = $(el).text().trim(); | ||
pages, | ||
searchDelay = 0, | ||
...options | ||
@@ -289,2 +291,3 @@ }) { | ||
pagesResults.push(result); | ||
searchDelay && await sleep(searchDelay); | ||
} | ||
@@ -291,0 +294,0 @@ return pagesResults; |
{ | ||
"name": "google-sr", | ||
"version": "3.2.1", | ||
"version": "3.3.0", | ||
"description": "Fast and efficient Package for scraping Google search results without the need for an API key", | ||
"repository": "typicalninja/google-sr", | ||
"repository":"https://github.com/typicalninja/google-sr", | ||
"homepage": "https://g-sr.vercel.app/google/sr", | ||
@@ -15,2 +15,6 @@ "main": "dist/index.js", | ||
}, | ||
"scripts": { | ||
"test": "mocha --require ts-node/register tests/*.ts", | ||
"build": "tsup" | ||
}, | ||
"keywords": [ | ||
@@ -34,3 +38,3 @@ "google-sr", | ||
"tslib": "^2.6.1", | ||
"google-sr-selectors": "^0.0.2" | ||
"google-sr-selectors": "workspace:^" | ||
}, | ||
@@ -45,7 +49,3 @@ "devDependencies": { | ||
"typescript": "^5.1.6" | ||
}, | ||
"scripts": { | ||
"test": "mocha --require ts-node/register tests/*.ts", | ||
"build": "tsup" | ||
} | ||
} | ||
} |
@@ -52,9 +52,15 @@ # google-sr 🔍 | ||
```ts | ||
import { search } from 'google-sr'; | ||
import { search, ResultTypes } from 'google-sr'; | ||
search({ query: 'nodejs' }).then(console.log); | ||
// using await/async | ||
const searchResults = await search({ | ||
query: 'nodejs', | ||
safeMode: false, | ||
filterResults: [ResultTypes.SearchResult] | ||
}); | ||
// or if using await/async | ||
const searchResults = await search({ query: 'nodejs' }); | ||
// will return a [] | ||
console.log(searchResults); | ||
// should log: true | ||
console.log(searchResults[0].type === ResultTypes.SearchResult) | ||
``` | ||
@@ -61,0 +67,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
48760
8
776
111
- Removedgoogle-sr-selectors@0.0.2(transitive)