Skip to content

Feature Request: Add renderMode to fetchWebContent for explicit Playwright/browser rendering | 新功能:为 fetchWebContent 增加 renderMode,支持显式使用 Playwright / 浏览器渲染 #89

Description

@Aas-ee

Feature Request: Add renderMode to fetchWebContent for explicit Playwright/browser rendering

Background

Currently, fetchWebContent mainly uses the request-based path and only falls back to browser-assisted fetching in limited cases, such as bot challenge pages, very low
extracted content, or some 401/403/429 responses.

However, some websites rely heavily on client-side JavaScript rendering. For these pages, request-based fetching may return an empty shell or incomplete content, and the current
automatic fallback may not always trigger.

Proposal

Add an explicit renderMode parameter to fetchWebContent:

renderMode?: "request" | "auto" | "browser"

Suggested behavior:

  • request: use the current request-based behavior only
  • auto: keep the current behavior, request first with browser fallback when needed
  • browser: directly use Playwright/browser rendering to load the page and extract content

The default should remain auto or the current behavior, so existing users are not affected.

Expected Benefits

  • Allows users and agents to explicitly fetch JS-rendered pages with Playwright
  • Avoids overloading searchMode, which currently only affects Bing search
  • Keeps normal request-based fetching fast and lightweight by default
  • Makes browser rendering an intentional opt-in instead of an implicit fallback

Safety Notes

The implementation should still preserve the existing safety checks:

  • Validate the initial URL before navigation
  • Validate the final URL after browser navigation
  • Keep blocking private/local network targets by default
  • Return a clear error when Playwright or a browser executable is unavailable

功能请求:为 fetchWebContent 增加 renderMode,支持显式使用 Playwright / 浏览器渲染

背景

目前 fetchWebContent 主要走 request 抓取路径,只会在少数场景下尝试浏览器兜底,例如遇到 bot challenge、提取内容过少,或者部分 401/403/429 响应。

但有些网站严重依赖前端 JavaScript 渲染。对于这类页面,request 抓取可能只能拿到空壳 HTML 或不完整内容,而当前自动兜底不一定总能触发。

建议方案

给 fetchWebContent 增加一个显式参数:

  renderMode?: "request" | "auto" | "browser"

建议行为:

  • request:只使用当前 request 抓取逻辑
  • auto:保持当前行为,先 request,必要时浏览器兜底
  • browser:直接使用 Playwright / 浏览器加载页面并提取内容

默认值应保持为 auto 或当前行为,避免影响现有用户。

预期收益

  • 允许用户和 Agent 显式抓取 JS 渲染页面
  • 避免复用 searchMode,因为它目前只影响 Bing 搜索
  • 普通网页默认仍然保持轻量、快速的 request 抓取
  • 浏览器渲染变成明确的用户选择,而不是隐式兜底

安全注意事项

实现时仍然应保留现有安全检查:

  • 浏览器导航前校验初始 URL
  • 浏览器导航后校验最终 URL
  • 默认继续阻止本地 / 内网地址
  • Playwright 或浏览器不可用时返回清晰错误

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions