-
Notifications
You must be signed in to change notification settings - Fork 107
[WIP] Add publisher pravda (Ukrainska Pravda) #807
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
Open
bucheben
wants to merge
1
commit into
flairNLP:master
Choose a base branch
from
bucheben:pr-pravda
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/")), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") | ||
|
|
||
| @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)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
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. The test article seems to be from a different publisher. Could you add a more suitable test case. |
||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This publisher also includes sub-headlines as seen in this article. Could you add a selector for that as well?