-
Notifications
You must be signed in to change notification settings - Fork 111
feat(publisher): add VOAParser V1_1 with enhanced selectors
#972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,11 +16,18 @@ | |
|
|
||
| class VOAParser(ParserProxy): | ||
| class V1(BaseParser): | ||
| _paragraph_selector = CSSSelector("#article-content > div > p") | ||
| VALID_UNTIL = datetime.date(2026, 7, 20) | ||
|
|
||
| _paragraph_selector: XPath = CSSSelector("#article-content > div > p") | ||
| _subheadline_selector: Optional[XPath] = None | ||
|
|
||
| @attribute | ||
| def body(self) -> Optional[ArticleBody]: | ||
| return extract_article_body_with_selector(self.precomputed.doc, paragraph_selector=self._paragraph_selector) | ||
| return extract_article_body_with_selector( | ||
| self.precomputed.doc, | ||
| paragraph_selector=self._paragraph_selector, | ||
| subheadline_selector=self._subheadline_selector, | ||
| ) | ||
|
|
||
| @attribute | ||
| def publishing_date(self) -> Optional[datetime.datetime]: | ||
|
|
@@ -46,3 +53,7 @@ def images(self) -> List[Image]: | |
| upper_boundary_selector=XPath("//h1"), | ||
| lower_boundary_selector=XPath("//div[@id='ymla-section']"), | ||
| ) | ||
|
|
||
| class V1_1(V1): | ||
| _paragraph_selector = XPath("//div[@id='article-content']/div/p[not(strong)]") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocker — V1_1 returns an empty body on VOA's featured-article layout. There the prose sits at Fix: |
||
| _subheadline_selector = XPath("//div[@id='article-content']/div/p[strong]") | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit — this
VALID_UNTILmarks a layout change the HTML doesn't show. On current pages V1 and V1_1 extract the same text to the character (on the new fixture both 11940 chars); V1_1 only re-labels the<p><strong>headings as subheadlines instead of paragraphs. So V1 was never "no longer able to extract articles properly" (how_to_add_a_publisher.md), and nothing observable picks 2026-07-20. The date is structurally required — two versions atdate.maxraise inParserProxy— so could the PR just say what it's based on?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before your other comment, you were right, that I could have just added subheadline support for
V1, but now it was also unable to parse the featured articles.