Read a page with web_fetch
web_fetch reads one public HTTP or HTTPS URL through the SerpApi Extract API. Use it to read a page found by web_search.
from serpapi_search_tools import web_fetch
fetch = web_fetch(provider="function")
markdown = fetch(url="https://example.com")
print(markdown)The agent supplies only url. The tool uses engine="extract" and mode="scrape". It does not execute JavaScript. Use web_map to discover URLs or web_crawl to read linked pages.
Response modes
Markdown output preserves the API response, including whitespace, headings, and links. For ordinary pages it contains the page content. If a Google or Bing search URL redirects to its dedicated engine, it can contain search results and metadata instead.
| Configuration | Returned value |
|---|---|
| Default, or any Markdown configuration | The API’s output=md response unchanged |
response_format="json" |
A JSON string containing only {"markdown":"..."} |
mode="full", response_format="json" |
The complete JSON response |
Compact JSON raises SerpApiSearchError if the response has a missing or empty markdown field. Use full JSON to read the available metadata, structured page fields, or a redirected engine’s response. To omit Markdown from full JSON, set default_params={"include_markdown": False}.
Configure extraction
from serpapi_search_tools import web_fetch
fetch = web_fetch(
provider="function",
timeout=90,
default_params={
"include_tags": "main,article",
"exclude_tags": "nav,footer,.ads",
"timeout": 30000,
},
)The constructor’s timeout controls the SDK request in seconds. default_params["timeout"] controls the Extract API’s page fetch in milliseconds. Other settings include device, prefetch_delay, and no_cache.
See Common configuration for provider and client options and the Extract API reference for supported page filters.