|Sven Slootweg 96c450d084 Release 0.0.1||5 years ago|
|lib||5 years ago|
|.gitignore||5 years ago|
|README.md||5 years ago|
|gulpfile.js||5 years ago|
|index.coffee||5 years ago|
|package.json||5 years ago|
|publish.sh||5 years ago|
|sample.cdx||5 years ago|
|test.coffee||5 years ago|
A simple streaming CDX file parser. Parses CDX files (in particular, those corresponding to WARC files) that correspond to the format as specified by the Internet Archive. All items in the CDX field legend are supported, plus the
cdx currently only reads (compliant) CDX streams. In the future, it will likely be expanded to also be able to write CDX streams, but this is not currently supported. Error handling is currently nearly non-existent - you are expected to provide a compliant CDX stream.
npm install --save cdx
cdx is a streaming parser. It takes a CDX byte stream as input (regardless of the source), and outputs an object stream of
CDXRecord objects with the named attributes set to the corresponding values from the CDX stream. Additionally, a plain object containing these attributes is available as the
data attribute, for easy (JSON) serialization.
The signature is automatically parsed from the first line of the CDX data. Specifying a custom signature is not currently supported. If a field is not specified (that is, it is either not listed in the signature or its value is
-), it will simply not be set on the
var cdx = require("cdx"), fs = require("fs"); fs.createReadStream("sample.cdx") .pipe(cdx()) .pipe(...);
An example that parses the sample CDX file, 'picks out' the serializable data, and then outputs it to
stdout as serialized JSON, can be found in
sample.cdx (you'll need to install devDependencies first to actually run that file, though).
All fields are self-explanatory, hopefully. These are just adapted from the legend provided by the Internet Archive, so I really have no idea what most of these do.
.warc.gz, this is the gzipped size of the record)
.warc.gz, this is the gzipped starting position of the record, combine with size to get the ending position)
.warc.gz, this is the original mimetype of the document as specified by the origin webserver)
.warc.gz, this is the original URL that the document was retrieved from)
.warc.gz, this is the retrieval date of the record)
.warc.gz, this is the path to the WARC file that this record lives in - may not be useful, as it may refer to a path on a different filesystem)
.warc.gz, this is the HTTP status code encountered when retrieving the document)
Contributions welcome! Please file bugs on GitHub, and target pull requests at the
develop branch. Thank you!