Skip to content
Open
Show file tree
Hide file tree
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
43 changes: 43 additions & 0 deletions docs/supported_publishers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2945,6 +2945,49 @@
</table>


## UA-Publishers

<table class="publishers ua">
<thead>
<tr>
<th>Class&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</th>
<th>Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</th>
<th>URL&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</th>
<th>Languages</th>
<th>Missing&#160;Attributes</th>
<th>Deprecated&#160;Attributes</th>
<th>Additional&#160;Attributes&#160;&#160;&#160;&#160;</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>Pravda</code>
</td>
<td>
<div>Ukrainska Pravda</div>
</td>
<td>
<a href="https://www.pravda.com.ua">
<span>www.pravda.com.ua</span>
</a>
</td>
<td>
<code>en</code>
<code>ru</code>
<code>uk</code>
</td>
<td>
<code>images</code>
<code>topics</code>
</td>
<td>&#160;</td>
<td>&#160;</td>
</tr>
</tbody>
</table>


## UK-Publishers

<table class="publishers uk">
Expand Down
2 changes: 2 additions & 0 deletions src/fundus/publishers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from fundus.publishers.tr import TR
from fundus.publishers.tw import TW
from fundus.publishers.tz import TZ
from fundus.publishers.ua import UA
from fundus.publishers.uk import UK
from fundus.publishers.us import US
from fundus.publishers.za import ZA
Expand Down Expand Up @@ -104,6 +105,7 @@ class PublisherCollection(metaclass=PublisherCollectionMeta):
tr = TR
tw = TW
tz = TZ
ua = UA
uk = UK
us = US
za = ZA
20 changes: 20 additions & 0 deletions src/fundus/publishers/ua/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from fundus.publishers.base_objects import Publisher, PublisherGroup
from fundus.scraping.filter import inverse, regex_filter
from fundus.scraping.url import NewsMap, Sitemap

from .pravda import PravdaParser


class UA(metaclass=PublisherGroup):
default_language = "uk"

Pravda = Publisher(
name="Ukrainska Pravda",
domain="https://www.pravda.com.ua",
parser=PravdaParser,
sources=[
Sitemap("https://www.pravda.com.ua/sitemap/sitemap-archive.xml", languages={"uk", "en", "ru"}),
NewsMap("https://www.pravda.com.ua/sitemap/sitemap-news.xml", languages={"uk", "en", "ru"}),
],
url_filter=inverse(regex_filter("[^e]pravda.com.ua.*/news/")),
)
36 changes: 36 additions & 0 deletions src/fundus/publishers/ua/pravda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from datetime 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,
image_extraction,
)


class PravdaParser(ParserProxy):
class V1(BaseParser):
_paragraph_selector = CSSSelector("div.post_news_text > p")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This publisher also includes sub-headlines as seen in this article. Could you add a selector for that as well?


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

@attribute
def title(self) -> Optional[str]:
return self.precomputed.ld.xpath_search("NewsArticle/headline", scalar=True)

@attribute
def authors(self) -> List[str]:
return generic_author_parsing(self.precomputed.ld.xpath_search("ProfilePage/mainEntity/name"))

@attribute
def publishing_date(self) -> Optional[datetime]:
return generic_date_parsing(self.precomputed.ld.xpath_search("NewsArticle/datePublished", scalar=True))
26 changes: 26 additions & 0 deletions tests/resources/parser/test_data/ua/Pravda.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"V1": {
"authors": [
"Віктор Волокіта"
],
"body": {
"summary": [],
"sections": [
{
"headline": [],
"paragraphs": [
"Міністерство цифрової трансформації України та державне агентство з контролю за гральним та лотерейним бізнесом PlayCity вперше встановлять ліміти для гравців в азартні ігри.",
"Про це повідомляє пресслужба Мінцифри.",
"\"Розробили спільно з PlayCity документ, за яким українці самостійно визначають часові та фінансові ліміти для гри — на день, тиждень чи місяць. Використали найкращу світову практику, щоб боротися з ігровою залежністю в українців\", - йдеться в повідомленні.",
"Що передбачає документ:",
"Зазначається, що текст проєкту наказу опубліковано на сайті Мінцифри. Після громадського обговорення документ опрацюють та узгодять з державними органами. Далі — його приймуть.",
"Нагадаємо:",
"Державне агентство з контролю за гральним та лотерейним бізнесом PlayCity оголосило тендер на створення Реєстру осіб, яким обмежено участь в азартних іграх."
]
}
]
},
"publishing_date": "2025-10-24 15:26:00",
"title": "В Україні вперше встановлять ліміти для гравців азартних ігор"
}
}
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/resources/parser/test_data/ua/meta.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Pravda_2025_10_24.html.gz": {
"url": "https://epravda.com.ua/tehnologiji/yak-v-ukrajini-diyatimut-limiti-dlya-gravciv-azartnih-igor-813313",
"crawl_date": "2025-10-24 15:15:05.296765"
Comment on lines +2 to +4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test article seems to be from a different publisher. Could you add a more suitable test case.

}
}