# WARC（文件格式）

**WARC**（Web ARChive，网络归档）是一种文件格式，用于将多个数字资源——通常是网络爬虫采集的内容——连同相关元数据合并为单一的聚合归档文件。该格式的标准编号为 ISO 28500，是对[互联网档案馆](https://www.edgepedia.org/zh/internet-archive)早期 ARC 格式的修订与推广，后者曾用于将网络抓取内容存储为内容块的序列。<sup>[1](https://wwws.loc.gov/preservation/digital/formats/fdd/fdd000236.shtml)</sup>

| 关键事实 | 详情 |
|---|---|
| 标准 | ISO 28500《信息与文献——WARC 文件格式》；2009 年版与 2017 年版<sup>[2](https://www.iso.org/standard/44717.html)</sup><sup> • </sup><sup>[3](https://www.iso.org/cms/%20render/live/en/sites/isoorg/contents/data/standard/06/80/68004.html?browse=tc)</sup> |
| 结构 | 一个 WARC 文件由一个或多个 WARC 记录串联而成；每条记录由一个头部、一个内容块和两个换行符组成<sup>[1](https://wwws.loc.gov/preservation/digital/formats/fdd/fdd000236.shtml)</sup> |
| 记录类型 | 共八种：'warcinfo'、'response'、'resource'、'request'、'metadata'、'revisit'、'conversion' 和 'continuation'<sup>[1](https://wwws.loc.gov/preservation/digital/formats/fdd/fdd000236.shtml)</sup> |
| 必填字段 | 每条记录均须包含 WARC-Type、WARC-Date（UTC 时间戳）、WARC-Record-ID（一个 URI）和 Content-Length<sup>[4](https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/)</sup> |
| 压缩 | 无内部压缩；推荐使用逐记录压缩的 GZIP，由此形成常见的 .warc.gz 形式，可对单条记录进行随机访问<sup>[4](https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/)</sup> |
| 建议文件大小 | 建议以 1 GB（10^9<sup>9</sup> 字节）作为 WARC 文件的实际目标大小<sup>[5](https://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf)</sup> |
| MIME 类型 | application/warc<sup>[4](https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/)</sup> |
| 主要用户 | Common Crawl，其数十亿页面的抓取语料库以 WARC 存储（2013 年夏季从 ARC 切换而来）<sup>[6](https://www.commoncrawl.org/get-started)</sup> |

## 目的与设计

该格式的编写目的包括：存储来自 HTTP、DNS、FTP 等主流互联网应用层协议的载荷内容与控制信息；存储与其他已存数据相关联的任意元数据；在保持记录完整性的同时支持数据压缩；记录重复检测事件，以便在相同或高度相似的资源反复出现时减少存储；以及通过截断或分段来支持处理过长的记录。<sup>[7](https://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1-1_latestdraft.pdf)</sup> 内容块可以承载任何格式的资源，包括嵌入 HTML 页面中或从 HTML 页面链接的二进制图像或音视频文件。<sup>[1](https://wwws.loc.gov/preservation/digital/formats/fdd/fdd000236.shtml)</sup>

WARC 与旧版 ARC 格式的差异被设计得足够大，使软件工具能够明确无误地识别并正确处理两者，从而确保在过渡期间对大量现有 ARC 归档数据的访问不被打断。<sup>[7](https://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1-1_latestdraft.pdf)</sup>

## 记录结构

每条记录以一个遵循 HTTP/1.1 通用规则的头部开始，随后是一个内容块和两个换行符。<sup>[7](https://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1-1_latestdraft.pdf)</sup> 必填的命名字段记录该记录的日期、类型和长度，并支持对每个采集资源的检索。<sup>[1](https://wwws.loc.gov/preservation/digital/formats/fdd/fdd000236.shtml)</sup> WARC-Date 是 [ISO 8601](https://www.edgepedia.org/zh/iso-8601) 的 W3C 规范中的 UTC 时间戳，表示该记录创建时数据采集开始的时刻。<sup>[4](https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/)</sup>

八种记录类型分担一次抓取中的不同工作。'response' 记录保存原始 HTTP 响应（含其头部）；'request' 记录保存信息是如何被请求的；'metadata' 记录保存关于抓取过程的信息；'revisit' 记录记录一次重复检测事件；'conversion' 记录保存后续日期的转换结果，如提取的文本；'continuation' 记录承载某条记录因过长而无法放入一个文件的分段。<sup>[1](https://wwws.loc.gov/preservation/digital/formats/fdd/fdd000236.shtml)</sup><sup> • </sup><sup>[6](https://www.commoncrawl.org/get-started)</sup> 一个 WARC 文件不必包含任何特定的记录类型，但建议所有 WARC 文件都以一条 'warcinfo' 记录开头。<sup>[4](https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/)</sup>

可选字段用于增强完整性与关联性。WARC-Block-Digest 和 WARC-Payload-Digest 分别携带带标签的摘要值（如 SHA-1 Base32 值），分别作用于完整块和载荷；标准不推荐特定的摘要算法。<sup>[4](https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/)</sup> WARC-Truncated 记录内容块被截短的原因，原因包括 'length'、'time'、'disconnect' 和 'unspecified'。<sup>[4](https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/)</sup>

## 压缩与随机访问

WARC 格式不定义内部压缩；是否压缩以及如何压缩属于外部决策。<sup>[4](https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/)</sup> 互联网档案馆使用前身 ARC 格式的经验表明，简单的标准压缩能在保持随机访问的同时显著节省存储空间，因此该标准的附录 D 推荐使用“deflate”压缩的 GZIP。<sup>[4](https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/)</sup>

通常的做法是逐记录压缩：一个合法的 GZIP 文件可以由任意数量的独立压缩“成员”组成，因此一个 .warc.gz 文件可以为每条 WARC 记录保存一个 gzip 流并串联在一起。外部索引随后记录每条记录的起始位置，从而无需解压前面所有记录即可对单条记录进行随机访问。<sup>[4](https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/)</sup><sup> • </sup><sup>[1](https://wwws.loc.gov/preservation/digital/formats/fdd/fdd000236.shtml)</sup> 诸如 Python 的 warcio 库之类的工具利用字节偏移直接定位到远程文件中的某条记录，并只解压该记录。<sup>[8](https://github.com/commoncrawl/whirlwind-python)</sup>

## 历史

ARC 格式由互联网档案馆为 [Alexa Internet](https://www.edgepedia.org/zh/alexa-internet) 爬虫的数据而创建，其发展为标准化的 WARC，标志着互联网档案馆从内部聚焦的实践转向以国际互联网保存联盟（IIPC）为中心的全球协作采集社区——该联盟由互联网档案馆与 11 家国家图书馆于 2003 年成立。<sup>[9](https://journals.sagepub.com/doi/pdf/10.1177/20539517231163172)</sup> WARC 的开发始于 2005 年，是 IIPC 领导的项目，与 Heritrix 归档爬虫（2004 年）和 Open Wayback 回放软件（2007 年）同期推进。<sup>[9](https://journals.sagepub.com/doi/pdf/10.1177/20539517231163172)</sup> 自 2008 年推出以来，该格式已成为大规模网络数据分析中所用网络归档存储的标准。<sup>[10](https://arxiv.org/abs/2112.03103)</sup>

该格式存在两个版本：1.0 和 1.1。在 WARC 1.0 中，正式规范要求 WARC-Target-URI 字段中的 URL 值用尖括号括起，但随附的示例却省略了尖括号；大多数实现照抄了示例，但 [Wget](https://www.edgepedia.org/zh/wget) 成为显著的例外——它于 2016 年 2 月加上了尖括号，结果破坏了大量解析其输出的软件。尖括号在 WARC 1.1 中被彻底取消。<sup>[11](https://www.loc.gov/preservation/digital/formats/fdd/fdd000236.shtml?loclr=blogsig)</sup>

## 大规模应用：Common Crawl

[Common Crawl](https://www.edgepedia.org/zh/common-crawl) 是一个可公开访问的数十亿页面网络语料库，其原始抓取数据以 WARC 文件存储在 AWS S3 上，并在 [Hugging Face](https://www.edgepedia.org/zh/hugging-face) 上部分镜像；2013 年夏季之前它使用的是 ARC 格式。<sup>[6](https://www.commoncrawl.org/get-started)</sup> 其 WARC 文件大小约 1 GB，每个文件包含约 30,000 个网页，整个语料库由大约 2,400 万个此类文件构成。<sup>[8](https://github.com/commoncrawl/whirlwind-python)</sup> 除 WARC 文件外，Common Crawl 还发布包含计算所得元数据的 WAT 文件和包含提取纯文本的 WET 文件，二者本身也采用 WARC 格式。<sup>[6](https://www.commoncrawl.org/get-started)</sup><sup> • </sup><sup>[8](https://github.com/commoncrawl/whirlwind-python)</sup> 在 2024 年的一项研究中，莫兹拉基金会判定，2019 至 2023 年间发布的 47 个大型语言模型中，至少有 64% 使用了经过滤的 Common Crawl 数据——其原始层即为 WARC——进行训练。<sup>[12](https://www.commoncrawl.org/about)</sup>

## 性能批评与打包替代方案

研究人员记录了批处理中的开销。2020 年的一项研究将批处理工作负载的显著性能损失归因于 WARC 的数据结构、编码和寻址方式，并表明仅通过将 WARC 文件重新格式化为 Parquet 或 Avro 即可实现一到两个数量级的性能提升。<sup>[13](https://arxiv.org/abs/2003.14046)</sup> 在 TB 或 PB 级别，解析工具中哪怕很小的低效也会累积，这促成了 FastWARC 的诞生——一个用 C++/Cython 编写的高性能 Python WARC 处理库，相比 warcio 库带来 1.6 至 8 倍的提升。<sup>[10](https://arxiv.org/abs/2112.03103)</sup>

为在浏览器中回放，Webrecorder 社区的 WACZ（Web Archive Collection Zipped，网络归档集合压缩包）格式将 WARC 数据、CDXJ 索引和页面列表打包进一个 ZIP 文件，使浏览器只需从静态托管的文件中获取某页面所需的内容即可渲染该页面，而无需专用的回放服务器。<sup>[14](https://github.com/webrecorder/specs/blob/main/wacz/1.2.0/index.md)</sup> WACZ 的规范将其描述为一种打包约定，而非对 WARC 本身的替代。<sup>[14](https://github.com/webrecorder/specs/blob/main/wacz/1.2.0/index.md)</sup>

## References

1. [WARC, Web ARChive file format, Library of Congress Format Description fdd000236](https://wwws.loc.gov/preservation/digital/formats/fdd/fdd000236.shtml)
2. [ISO 28500:2009, Information and documentation \u2014 WARC file format, ISO](https://www.iso.org/standard/44717.html)
3. [ISO 28500:2017, Information and documentation \u2014 WARC file format, ISO](https://www.iso.org/cms/%20render/live/en/sites/isoorg/contents/data/standard/06/80/68004.html?browse=tc)
4. [The WARC Format (ISO 28500, version 1.1), IIPC WARC Specifications](https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/)
5. [ISO/DIS 28500 version 1 latest draft, Biblioth\u00e8que nationale de France](https://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf)
6. [Common Crawl \u2013 Get Started](https://www.commoncrawl.org/get-started)
7. [ISO/DIS 28500:2016(E), WARC file format, version 1.1 draft, Biblioth\u00e8que nationale de France](https://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1-1_latestdraft.pdf)
8. [commoncrawl/whirlwind-python: A whirlwind tour of Common Crawl's data using Python, GitHub](https://github.com/commoncrawl/whirlwind-python)
9. [All WARC and no playback: The materialities of data-centered web archives research, Big Data & Society](https://journals.sagepub.com/doi/pdf/10.1177/20539517231163172)
10. [FastWARC: Optimizing Large-Scale Web Archive Analytics, arXiv:2112.03103](https://arxiv.org/abs/2112.03103)
11. [WARC, Web ARChive file format (Notes), Library of Congress Format Description fdd000236](https://www.loc.gov/preservation/digital/formats/fdd/fdd000236.shtml?loclr=blogsig)
12. [Common Crawl \u2013 About](https://www.commoncrawl.org/about)
13. [The Case For Alternative Web Archival Formats To Expedite The Data-To-Insight Cycle, arXiv:2003.14046](https://arxiv.org/abs/2003.14046)
14. [WACZ specification version 1.2.0, Webrecorder specs](https://github.com/webrecorder/specs/blob/main/wacz/1.2.0/index.md)

---
*Initially written Oct 15, 2026 · Edited: Oct 25, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › 数据格式与序列化 › 文本、编码与归档

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/warc-file-format

English original: https://www.edgepedia.org/warc-file-format
