serpapi / serpapi-javascript

Scrape and parse search engine results using SerpApi.
https://serpapi.com
MIT License
45 stars 4 forks source link

Accept search params as the first arg for `getJson`/`getHtml` #7

Closed sebastianquek closed 1 year ago

sebastianquek commented 1 year ago

Search parameters can be now be sent in as the first argument of getJson and getHtml instead of the engine argument. Note that you won't get auto-completions for the supported search parameters for that engine.

// Show result as JSON (async/await with search params as first argument)
const response2 = await getJson({ engine: "google", ...params });
console.log(response2["organic_results"]);

Related to https://github.com/serpapi/serpapi-javascript/issues/5

sebastianquek commented 1 year ago

Closing this in light of recent findings into better approaches: https://github.com/serpapi/serpapi-javascript/issues/5#issuecomment-1429529621