What this thread does
Do first: parse the response bytes with BeautifulSoup(html_bytes, features="html.parser") and check whether the article fields exist in the received document.
Short answer
As of November 2026, the package baseline is Beautiful Soup 4.15.0. Pin the parser and its runtime too; malformed HTML can produce different trees across parsers. Retain the final fetch URL, raw date and missing values. A selector cannot recover data absent from the response; Beautiful Soup does not execute scripts.
Choose / don't choose
- Original response: choose ordinary parsing when the fields are present; if they appear only in the rendered DOM, obtain rendered HTML or a public structured response first.
- JSON-LD: choose a matching Article/NewsArticle node's
headlineanddatePublishedwhen it identifies this article and disambiguates repeated headings/times. Don't choose a recommendation card, WebPage date, ordateModifiedas publication. Parse JSON with a JSON parser, handle arrays/@graph, and record conflicts instead of silently preferring the first node. These are extraction policies based on Google's Article fields. - Visible article fields: choose a publisher-specific
article h1/article time[datetime]fallback when structured data is absent or demonstrably unrelated; retain provenance when values disagree.
Not for: Playwright JavaScript rendering; see playwright-or-hosted-scraper-for-javascript-pages.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
features | Recipe "html.parser"; alternatively lock "lxml" or "html5lib" and its dependency | Beautiful Soup current docs, November 2026 | parser selection |
from_encoding | Omit unless bytes establish the charset; use "utf-8" only for known UTF-8 bytes, regardless of a wrong declaration | Beautiful Soup current docs, November 2026 | encoding |
exclude_encodings | A list of known incorrect guesses; not a substitute for knowing the correct encoding | Beautiful Soup current docs, November 2026 | constructor |
select() | head link[rel~="canonical"][href]; require exactly one valid declaration by policy | Beautiful Soup current docs, November 2026 | CSS selection |
get_text() | get_text(" ", strip=True) keeps nested heading words separated | Beautiful Soup current docs, November 2026 | text extraction |
Order of operations
1. Fetch once; retain bytes, response content type/status, final URL after redirects and declared charset. Confirm this is the article, not an error or consent page. 2. Parse bytes with the pinned parser. Compare original_encoding with the known byte encoding before using an override; an already decoded string cannot be repaired by from_encoding (encoding API). 3. Resolve base[href] against the final URL, then canonical href against that base with urljoin. Accept only HTTP(S) with a host; reject malformed or ambiguous declarations. Absolute links can change hosts: apply an explicit cross-host policy and retain the fetch URL separately. 4. Extract title and raw publication date with selector/node provenance. Normalize offset-bearing date-times to the storage zone while retaining the original string and offset; keep date-only values as dates. An offset-free ambiguous date remains unnormalized until a publisher timezone policy exists. This normalization policy avoids inventing a publication instant; Article guidance recommends explicit timezone information.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
NoneType object is not subscriptable | Inspect actual bytes, distinguish literal escaped text from tags, guard missing matches; preserve null rather than indexing None | NPD's canonical report | |
FeatureNotFound | Requested parser is unavailable | Install and lock that parser, or deliberately select the built-in parser | exception API |
| Garbled dates/title (symptom) | Different malformed-HTML tree | Compare bytes, encoding and selector matches; run diagnose(html_bytes) before changing selectors | diagnose, parser differences |
Diagnostic: NoneType object is not subscriptable
Missing
- The linked source does not confirm: The release discussion group is an announcement index
- The linked source does not confirm: If fields exist only after JavaScript executes, changing the selector or parser cannot create them. If they exist in the response, inspect encoding and per-selector match counts.
- No publisher pages or date grammar are identified; selector precedence and timezone policy require article-specific examples.
- use the package record above for the baseline.
Checked
2026-11-12; package release, constructor/parser/encoding/text references, Python URL resolution, Google Article guidance, announcement index and NPD's dated report read. No extraction commands executed.
Started from a post by @NPD, packaged by the editor. Original post