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

Add Ruhr Nachrichten #496

Merged
merged 6 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
17 changes: 17 additions & 0 deletions docs/supported_publishers.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,23 @@
<td>&#160;</td>
<td>&#160;</td>
</tr>
<tr>
<td>
<code>RuhrNachrichten</code>
</td>
<td>
<div>Ruhr Nachrichten</div>
</td>
<td>
<a href="https://www.ruhrnachrichten.de/">
<span>www.ruhrnachrichten.de</span>
</a>
</td>
<td>
<code>topics</code>
</td>
<td>&#160;</td>
</tr>
<tr>
<td>
<code>SpiegelOnline</code>
Expand Down
12 changes: 12 additions & 0 deletions src/fundus/publishers/de/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from .tagesschau import TagesschauParser
from .taz import TazParser
from .waz import WAZParser
from .rn import RuhrNachrichtenParser


# noinspection PyPep8Naming
Expand Down Expand Up @@ -240,3 +241,14 @@ class DE(PublisherEnum):
],
parser=RheinischePostParser,
)

RuhrNachrichten = PublisherSpec(
name="Ruhr Nachrichten",
domain="https://www.ruhrnachrichten.de/",
sources=[
RSSFeed("https://www.ruhrnachrichten.de/service/feed/"),
Sitemap("https://www.ruhrnachrichten.de/sitemap_index.xml"),
NewsMap("https://www.ruhrnachrichten.de/news-sitemap.xml"),
],
parser=RuhrNachrichtenParser,
)
35 changes: 35 additions & 0 deletions src/fundus/publishers/de/rn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import datetime
from typing import List, Optional

from lxml.cssselect import CSSSelector

from fundus.parser import ArticleBody, BaseParser, ParserProxy, attribute
from fundus.parser.utility import (
extract_article_body_with_selector,
generic_author_parsing,
generic_date_parsing,
)

class RuhrNachrichtenParser(ParserProxy):
class V1(BaseParser):
_paragraph_selector = CSSSelector("div[class*=article-body] > p")
MaxDall marked this conversation as resolved.
Show resolved Hide resolved

@attribute
def body(self) -> ArticleBody:
return extract_article_body_with_selector(
self.precomputed.doc,
paragraph_selector=self._paragraph_selector,
)

@attribute
def publishing_date(self) -> Optional[datetime.datetime]:
return generic_date_parsing(self.precomputed.ld.bf_search("datePublished"))

@attribute
def authors(self) -> List[str]:
return generic_author_parsing(self.precomputed.ld.bf_search("author"))

@attribute
def title(self) -> Optional[str]:
return self.precomputed.meta.get("og:title")