一个维基百科页面就要消耗你的 AI 代理 68,000 tokens
英文标题:🔶 One Wikipedia page costs your AI agent 68,000 tokens
作者日常使用 Claude Code,实测发现单个维基百科页面的原始 HTML 平均占用 68,240 tokens(tiktoken 计数),Nike 首页更高达 353,000 tokens。Claude Code 内置的 webfetch 虽能将维基百科摘要压缩到约 950 tokens,并能绕过部分 Cloudflare 防护,但面对 JavaScript 渲染页面和部分反爬机制时却会失败,甚至返回 403 错误,导致代理被迫加载大量原始 HTML。为此作者构建了一个开源隐身浏览器(基于重新编译的 Chromium),通过 MCP 协议集成到 Claude Code、Cursor 和 Claude Desktop 中,可将 Nike 页面压缩到约 700 tokens,JS 引号页面压缩到 285 tokens,并成功绕过检测。这对需要让 AI 代理稳定访问网页的开发者具有实际参考价值,项目已开源并附有可复现基准测试。
43 B
中文
我每天都在使用 Claude Code,并测量了它在进行调研时访问网页所消耗的 token。例如,一个普通的维基百科页面,原始 HTML 平均占用 68,240 tokens(使用 tiktoken 计数);Nike 的主页甚至高达 353,000 tokens。
Claude Code 内置的 webfetch 在简单场景下表现不错。它会把维基百科内容总结到大约 950 tokens,并且在 Indeed 和 Ticketmaster 等网站上能绕过 Cloudflare。但是——总有一个“但是”——在面对需要 JavaScript 渲染的页面,或某些反爬虫页面时,它却什么也返回不了。
例如,quotes.toscrape.com/js 会返回“未找到引号”;nike.com 会返回 403 错误。于是你的代理就会把原始 HTML 重新塞回上下文,但结果仍然失败。(注:我也曾在事后翻阅聊天记录时发现它其实已经失败了,最后只是从训练数据或其他来源的陈旧缓存中取了内容。)
因此,我着手构建了一个开源的隐身浏览器(基于重新编译的 Chromium),它以 MCP 的方式运行,可用于 Claude Code、Cursor 和 Claude Desktop。对我来说,基本上只需要在本地添加这个 MCP 即可。它不仅能返回清洗后的 token,同时还能绕过检测:JS 生成的引号页面只返回 285 tokens,Nike 页面约 700 tokens,而不再是 403 错误。
目前我还在积极解决一些问题:暂时还没有住宅 IP 出口,也无法突破 Kasada 级别的防护墙。它的定位是面向代理、QA 和调研用途。
仓库及可复现基准测试:https://github.com/tiliondev/fortress/tree/main/mcp 我是作者,欢迎提出反馈。
English / 原文
i use claude code daily and measured what pages cost it while doing research. an average wikipedia article, for instance, is 68,240 tokens of raw html (tiktoken); nike's homepage is 353,000.
claude code's built-in webfetch handles the easy case well. it summarizes wikipedia to about 950 tokens and clears cloudflare on some sites like indeed and ticketmaster. but, and there's always a but, on js-rendered and some anti-bot pages it returns nothing.
quotes.toscrape.com/js gives "no quotes found"; nike.com gives a 403. your agent then dumps the raw html back into context and still fails. (note: i have also had cases where i read through the chat at the end and saw that it failed and just pulled from either training data or stale caches from other sources)
so i worked on building an open-source stealth browser (recompiled chromium) that runs as an mcp for claude code, cursor, and claude desktop. essentially all i have to change form my end is add the mcp, and it returns the cleaned up tokens while also beating detection: the js quotes come back in 285 tokens, nike in about 700 instead of a 403.
there is still stuff i am actively working on: there's no residential egress yet, and it won't beat kasada-style walls. it's for agents, qa, and research.
repo and the reproducible benchmark: https://github.com/tiliondev/fortress/tree/main/mcp i'm the author and here for feedback.