Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Screenshot format writes URL text to file instead of downloading image binary

未关闭 适合新手
#82 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
领域
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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firecrawl/cli 的其他 Issue

查看 firecrawl/cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。