Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions python/smart-fetch-scraper/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# Tries the Browserbase Fetch API first (fast, no browser session needed).
# If the page is JS-rendered or the content is insufficient, falls back to
# a full Stagehand browser session with AI-powered extraction.
#
# Note: the Fetch API can return content as `raw` HTML, clean `markdown`,
# or schema-extracted `json` — pass `format="markdown"` or `format="json"`
# (with a JSON schema) to `bb.fetch_api.create` to skip writing your own
# HTML parser. Docs: https://docs.browserbase.com/platform/fetch/overview

import asyncio
import json
Expand Down Expand Up @@ -116,6 +121,9 @@ async def try_fetch_api(url: str) -> dict | None:
print("[Fetch API] Attempting lightweight fetch...")

try:
# Tip: pass `format="markdown"` or `format="json"` (with a `schema`)
# here to have Browserbase return cleaner content or structured data
# directly — see https://docs.browserbase.com/platform/fetch/overview
# Use asyncio.to_thread for synchronous SDK calls
data = await asyncio.to_thread(bb.fetch_api.create, url=url, allow_redirects=True)

Expand Down
8 changes: 8 additions & 0 deletions typescript/smart-fetch-scraper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
// Tries the Browserbase Fetch API first (fast, no browser session needed).
// If the page is JS-rendered or the content is insufficient, falls back to
// a full Stagehand browser session with AI-powered extraction.
//
// Note: the Fetch API can return content as `raw` HTML, clean `markdown`,
// or schema-extracted `json` — pass `format: "markdown"` or `format: "json"`
// (with a JSON schema) to `bb.fetchAPI.create` to skip writing your own
// HTML parser. Docs: https://docs.browserbase.com/platform/fetch/overview

import "dotenv/config";
import Browserbase from "@browserbasehq/sdk";
Expand Down Expand Up @@ -91,6 +96,9 @@ async function tryFetchApi(url: string): Promise<{ content: string; statusCode:
console.log("[Fetch API] Attempting lightweight fetch...");

try {
// Tip: pass `format: "markdown"` or `format: "json"` (with a `schema`)
// here to have Browserbase return cleaner content or structured data
// directly — see https://docs.browserbase.com/platform/fetch/overview

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing format: "markdown" parameter in API calls

High Severity

The PR title and description state that tryFetchApi/try_fetch_api "now pass format: 'markdown'" to the Fetch API, but the actual calls in both TypeScript and Python still only pass url and allowRedirects/allow_redirects — the format parameter is entirely absent. The added comments say "Tip: pass format…" as if it's optional guidance, contradicting the stated intent. Since the downstream code still uses parseFromHtml/parse_from_html (HTML regex parsing) and the MIN_TEXT_DENSITY HTML heuristic, the template doesn't demonstrate the new markdown format at all.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 822afc6. Configure here.

const data = await bb.fetchAPI.create({ url, allowRedirects: true });

console.log(
Expand Down