Screenshot format writes URL text to file instead of downloading image binary
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- node.js, typescript
- 领域
- cli
调研方向
从 src/commands/scrape.ts 中的 handleScrapeCommand,以及 src/utils/output.ts 中的 handleScrapeOutput 和 formatScreenshotOutput 开始。复现 issue 中的单 URL 命令,然后将其与 handleAllScrapeCommand 中的二进制写入路径进行比较。完成的标准是图像输出包含有效的已下载 PNG 或其他图像字节,而不是截图 URL 文本。
由索引模型根据 Issue 内容生成。
描述
Bug
When using firecrawl scrape --format screenshot -o output.png, the CLI writes the screenshot URL as plain text to the output file instead of downloading the actual PNG image. This produces a corrupt file that appears to be a PNG but is actually a small text file containing the Firecrawl CDN URL.
Reproduction
firecrawl scrape "https://example.com" --format screenshot -o screenshot.png
file screenshot.png # Reports: ASCII text, not PNG image data
cat screenshot.png # Shows: "Screenshot: https://..."
Expected behavior
The CLI should fetch the image from the screenshot URL and write the binary data to the output file (like handleAllScrapeCommand already does correctly for multi-URL scrapes).
Root cause
In src/commands/scrape.ts, handleScrapeCommand delegates to handleScrapeOutput in src/utils/output.ts. For a single screenshot format, handleScrapeOutput calls formatScreenshotOutput() which returns the URL as text, then writeOutput() writes that text string to the file with utf-8 encoding.
The multi-URL code path (handleAllScrapeCommand in the same file, ~line 470) correctly handles this by fetching the URL and writing the binary buffer:
const response = await fetch(result.data.screenshot);
if (response.ok) {
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync(filepath, buffer);
}
Suggested fix
In handleScrapeCommand, before calling handleScrapeOutput, check if the output is a single screenshot format going to an image file extension. If so, fetch the binary and write it directly:
const isScreenshotOnly = effectiveFormats.length === 1 && effectiveFormats[0] === 'screenshot';
const isImageOutput = options.output && /\.(png|jpg|jpeg|webp)$/i.test(options.output);
if (isScreenshotOnly && isImageOutput && result.success && result.data?.screenshot) {
const response = await fetch(result.data.screenshot);
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync(options.output, buffer);
return;
}
Environment
- firecrawl-cli 1.10.0
- Windows 11 / Node.js
- 主要语言
- TypeScript
- 星标
- 635
- 派生
- 106
- 平均合并
- 4 小时 52 分钟
- 30 天内合并 PR
- 43
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
firecrawl/cli 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
firecrawl/cli#160 · 1 个 reaction ·
维护者通常 1 天内回复
相似的 Issue
-
ADD openalgo未关闭template
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
factory-active factory-automatic task-bug-reproduction-success task-identify-harness-labels-done task-identify-issue-type-done
难度 2/5 1-3 小时 新手友好度 90/100
维护者通常 1 天内回复
-
bug Needs: Triage :mag:
难度 2/5 1-3 小时 新手友好度 84/100
microsoft/fluentui-contrib#671 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
sveltejs/acorn-typescript#150 ·
-
难度 2/5 1-3 小时 新手友好度 78/100