我正在尝试通过以下链接使用工具箱使用python打开warc文件:http ://warc.readthedocs.org/en/latest/
使用以下方式打开文件时:
import warc
f = warc.open("00.warc.gz")
Run Code Online (Sandbox Code Playgroud)
一切都很好,并且f对象是:
<warc.warc.WARCFile instance at 0x1151d34d0>
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用以下方法读取文件中的所有内容时:
for record in f:
print record['WARC-Target-URI'], record['Content-Length']
Run Code Online (Sandbox Code Playgroud)
出现以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/xxx/anaconda/lib/python2.7/site-packages/warc/warc.py", line 390, in __iter__
record = self.read_record()
File "/Users/xxx/anaconda/lib/python2.7/site-packages/warc/warc.py", line 373, in read_record
header = self.read_header(fileobj)
File "/Users/xxx/anaconda/lib/python2.7/site-packages/warc/warc.py", line 331, in read_header
raise IOError("Bad version line: %r" % version_line)
IOError: Bad version line: 'WARC/0.18\n'
Run Code Online (Sandbox Code Playgroud)
这是因为我使用的warc工具箱不支持我的warc文件版本吗?