export type CreateApiSerperScrapeArgs = {body: {url: string, includeMarkdown?: boolean | undefined, includeHtml?: boolean | undefined}}; export type CreateApiSerperScrapeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Scrape any webpage and extract its content as clean text, markdown, or raw HTML. Handles JavaScript-rendered pages. Returns page text, metadata (title, description, OG tags), and optionally markdown/HTML. Use for content extraction, data gathering, or page analysis. * * POST /serper-scrape/ */ export const createApiSerperScrape = async (args: CreateApiSerperScrapeArgs, options?: CreateApiSerperScrapeOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/serper-scrape/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };