Skip to content
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

Adjust paragraph selector for Fox News parser #368

Merged
merged 3 commits into from
Feb 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/fundus/publishers/us/fox_news.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import List, Optional

from lxml.cssselect import CSSSelector
from lxml.etree import XPath

from fundus.parser import ArticleBody, BaseParser, ParserProxy, attribute
from fundus.parser.utility import (
Expand All @@ -14,7 +15,11 @@

class FoxNewsParser(ParserProxy):
class V1(BaseParser):
_paragraph_selector = CSSSelector(".article-body > p")
_summary_selector = CSSSelector(".article-meta > h2")
_paragraph_selector = XPath(
"(//div[@class='article-body'] | //div[@class='article-body']/div[contains(@class, 'paywall')]) "
"/p[not(child::script) and text()]"
MaxDall marked this conversation as resolved.
Show resolved Hide resolved
)

@attribute
def body(self) -> ArticleBody:
MaxDall marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading