Skip to main content
Module

x/serpapi/mod.ts>getHtmlBySearchId

Scrape and parse search engine results using SerpApi.
Go to Latest
function getHtmlBySearchId
import { getHtmlBySearchId } from "https://deno.land/x/serpapi@0.0.7/mod.ts";

Get a HTML response given a search ID.

  • This search ID can be obtained from the search_metadata.id key in the response.
  • Typically used together with the async parameter.
  • Accepts an optional callback.
  • Responds with a JSON if the search request hasn't completed.

Examples

const response = await getJson("google", { api_key: API_KEY, async: true, q: "coffee" }); const { id } = response.search_metadata; await delay(1000); // wait for the request to be processed.

// async/await const html = await getHtmlBySearchId(id, { api_key: API_KEY });

// callback getHtmlBySearchId(id, { api_key: API_KEY }, console.log);

Parameters

searchId: string
  • search ID
optional
parameters: GetBySearchIdParameters = [UNSUPPORTED]
optional
callback: (html: string) => void
  • API key