将warc.gz转换为.warc



我尝试使用gzip提取warc.gz文件,结果是warc,但它不会加载http://replayweb.page.

使用Unarchiver提取它给了我所有扩展的html和其他文件。

将warc.gz转换为warc的最新推荐方法是什么?出于某种原因,我在试图为这项简单的任务找到建议时做得不够。

谢谢!

编程方式是使用"warcio";python-lib,命令行方式是使用"warc2warc";warctools的实用程序。

在我尝试warc2warc失败后,我创建了以下小python脚本来完成这项任务。似乎工作得相当好!

用法:python warcgz-to-warc compressed.warc.gz -o output.warc

import argparse
import gzip
import shutil
import os
def convert_warc(input_file_path, output_file_path=None):
if output_file_path is None:
output_file_path = os.path.splitext(input_file_path)[0]
with gzip.open(input_file_path, 'rb') as f_in:
with open(output_file_path, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Convert a WARC file compressed with gzip to a WARC file.')
parser.add_argument('input_file_path', help='The path to the input WARC file.')
parser.add_argument('-o', '--output_file_path', help='The path to the output WARC file. If not provided, the output file will have the same name as the input file with the ".gz" extension removed.')
args = parser.parse_args()
convert_warc(args.input_file_path, args.output_file_path)

最新更新