Repository navigation
v0.2.0
Added
extract()acceptsbytesand decodes them: byte order mark, thenencoding=, then the page's<meta>declaration, then utf-8, falling back to cp1252. Legacy charset labels map the way browsers read them (latin1→ cp1252,shift_jis→ cp932,gb2312→ gb18030).- Keyword-only
encoding=onExtractor.extractandextract, for a charset known from an HTTP or WARC header. - Dependency:
w3lib(BSD-3-Clause) for charset sniffing. - Keyword-only
base_url=onExtractor.extractandextract: links and image URLs inhtmlandmarkdownoutput are made absolute against it. The page's first<base href>is resolved againstbase_url; malformed links are left as they are.textoutput andwith_blocksare unaffected. htmlsift extractcommand: files, quoted globs or stdin in; the content of a single input, or one JSON line per file (--jsonlto force), out. Flags--output,--mode,--device,--base-url,--encoding. Failed files are reported as records and the run exits with 1.
Changed
- Input other than
strorbytesraisesTypeError;extract(None)previously returned"". encoding=withstrinput raisesTypeError, since astris already decoded.- A page with an absolute
<base href>gets absolute links inhtmlandmarkdownoutput even withoutbase_url. Previously<base>was dropped with<head>, leaving its links relative.
Fixed
- Non-utf-8
bytesinput crashed withUnicodeDecodeError. htmlandmarkdownoutput could drop images and other inline content inside a kept block, varying from run to run on the same page.textoutput was unaffected.
Full changelog: v0.1.1...v0.2.0