-
Notifications
You must be signed in to change notification settings - Fork 75
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 20 Minuten
#638
Open
addie9800
wants to merge
5
commits into
master
Choose a base branch
from
add-20-minuten
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
Add 20 Minuten
#638
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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 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 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 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,41 @@ | ||
import datetime | ||
from typing import List, Optional | ||
|
||
from lxml.etree import XPath | ||
|
||
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 ZwanzigMinutenParser(ParserProxy): | ||
class V1(BaseParser): | ||
_summary_selector = XPath( | ||
"//div[@class='Article_elementLead__N3pGr']/p| " "//div[@type='typeInfoboxSummary']//li" | ||
) | ||
_subheadline_selector = XPath("//section[@class='Article_body__60Liu']//h2[contains(@class, 'crosshead')]") | ||
_paragraph_selector = XPath("//div[@class='Article_elementTextblockarray__WNyan']/p") | ||
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 list box at the beginning of this article isn't completely extracted. |
||
|
||
@attribute | ||
def body(self) -> Optional[ArticleBody]: | ||
return extract_article_body_with_selector( | ||
self.precomputed.doc, | ||
summary_selector=self._summary_selector, | ||
subheadline_selector=self._subheadline_selector, | ||
paragraph_selector=self._paragraph_selector, | ||
) | ||
|
||
@attribute | ||
def authors(self) -> List[str]: | ||
return generic_author_parsing(self.precomputed.ld.bf_search("author")) | ||
|
||
@attribute | ||
def publishing_date(self) -> Optional[datetime.datetime]: | ||
return generic_date_parsing(self.precomputed.ld.bf_search("datePublished")) | ||
|
||
@attribute | ||
def title(self) -> Optional[str]: | ||
return self.precomputed.meta.get("og:title") |
This file contains 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 @@ | ||
{ | ||
"V1": { | ||
"authors": [ | ||
"Simon Misteli" | ||
], | ||
"body": { | ||
"summary": [ | ||
"Laurent Vinatier wurde im Juni in Moskau festgenommen. Nun sprach ein Gericht drei Jahre Haft gegen ihn aus. Vorgeworfen wird ihm das Sammeln von Militärinformationen.", | ||
"Ein in Moskau verhafteter Franzose erhielt drei Jahre Gefängnisstrafe.", | ||
"Er arbeitete für das Schweizer NGO HD Centre.", | ||
"Im wird vorgeworfen, russische Militärinformationen gesammelt zu haben." | ||
], | ||
"sections": [ | ||
{ | ||
"headline": [], | ||
"paragraphs": [ | ||
"Anfang Juni wurde in Moskau der Franzose Laurent Vinatier festgenommen, der für das Schweizer NGO HD Centre (Zentrum für humanitären Dialog) gearbeitet hatte.", | ||
"Vorgeworfen wird ihm das Sammeln russischer Militärinformationen und eine fehlende Registrierung als «ausländischer Agent». Nun wurde er zu drei Jahren Haft im Straflager verurteilt." | ||
] | ||
}, | ||
{ | ||
"headline": [ | ||
"In Russland als Auslandsagent verurteilt" | ||
], | ||
"paragraphs": [ | ||
"Das Gericht verminderte somit die von der Staatsanwaltschaft verlangte Strafe. Diese forderte fünf Jahre Haft oder Zwangsarbeit. Die Verteidigung hatte eine Geldstrafe vorgeschlagen.", | ||
"«Ich bitte Russland um Verzeihung, dass ich die Gesetze der Russischen Föderation nicht beachtet habe», sagte Vinatier. Er kenne Russland seit 20 Jahren und habe sich in das Land verliebt, so zitiert ihn die russische Nachrichtenagentur Interfax.", | ||
"Gemäss dem russischen Gesetz über die sogenannten Auslandsagenten müssen sich Organisationen und Personen registrieren, die ganz oder teilweise aus dem Ausland finanziert werden. Das Gesetz wird oft dazu genutzt, Regierungskritiker zu verfolgen." | ||
] | ||
} | ||
] | ||
}, | ||
"publishing_date": "2024-10-15 21:01:17+02:00", | ||
"title": "Laurent Vinatier: Franzose in Russland zu drei Jahren Haft" | ||
} | ||
} |
Binary file added
BIN
+34.9 KB
tests/resources/parser/test_data/ch/ZwanzigMinuten_2024_10_15.html.gz
Binary file not shown.
This file contains 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
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.
We definitive need a solution for the mixed languages at some pint😅