Skip to content

v0.2.0

Choose a tag to compare

@koivualeksi koivualeksi released this 02 Nov 17:38
· 30 commits to main since this release
e63616c

Added

  • extract() accepts bytes and decodes them: byte order mark, then encoding=, 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= on Extractor.extract and extract, for a charset known from an HTTP or WARC header.
  • Dependency: w3lib (BSD-3-Clause) for charset sniffing.
  • Keyword-only base_url= on Extractor.extract and extract: links and image URLs in html and markdown output are made absolute against it. The page's first <base href> is resolved against base_url; malformed links are left as they are. text output and with_blocks are unaffected.
  • htmlsift extract command: files, quoted globs or stdin in; the content of a single input, or one JSON line per file (--jsonl to 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 str or bytes raises TypeError; extract(None) previously returned "".
  • encoding= with str input raises TypeError, since a str is already decoded.
  • A page with an absolute <base href> gets absolute links in html and markdown output even without base_url. Previously <base> was dropped with <head>, leaving its links relative.

Fixed

  • Non-utf-8 bytes input crashed with UnicodeDecodeError.
  • html and markdown output could drop images and other inline content inside a kept block, varying from run to run on the same page. text output was unaffected.

Full changelog: v0.1.1...v0.2.0