Skip to content

Add LS #762

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
wants to merge 2 commits into
base: master
Choose a base branch
from
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
38 changes: 38 additions & 0 deletions docs/supported_publishers.md
Original file line number Diff line number Diff line change
Expand Up @@ -1877,6 +1877,44 @@
</table>


## LS-Publishers

<table class="publishers ls">
<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>Additional&#160;Attributes&#160;&#160;&#160;&#160;</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>LesothoTimes</code>
</td>
<td>
<div>Lesotho Times</div>
</td>
<td>
<a href="https://lestimes.com/">
<span>lestimes.com</span>
</a>
</td>
<td>
<code>en</code>
</td>
<td>
<code>topics</code>
</td>
<td>&#160;</td>
</tr>
</tbody>
</table>


## LT-Publishers

<table class="publishers lt">
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 @@ -18,6 +18,7 @@
from fundus.publishers.isl import ISL
from fundus.publishers.it import IT
from fundus.publishers.jp import JP
from fundus.publishers.ls import LS
from fundus.publishers.lt import LT
from fundus.publishers.my import MY
from fundus.publishers.na import NA
Expand Down Expand Up @@ -78,6 +79,7 @@ class PublisherCollection(metaclass=PublisherCollectionMeta):
cz = CZ
be = BE
tr = TR
ls = LS
my = MY
pt = PT
pl = PL
Expand Down
21 changes: 21 additions & 0 deletions src/fundus/publishers/ls/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from fundus.publishers.base_objects import Publisher, PublisherGroup
from fundus.publishers.ls.lesotho_times import LesothoTimesParser
from fundus.scraping.filter import inverse, regex_filter
from fundus.scraping.url import Sitemap


class LS(metaclass=PublisherGroup):
default_language = "en"

LesothoTimes = Publisher(
name="Lesotho Times",
domain="https://lestimes.com/",
parser=LesothoTimesParser,
sources=[
Sitemap(
"https://lestimes.com/sitemap_index.xml",
sitemap_filter=inverse(regex_filter("post-sitemap")),
reverse=True,
),
],
)
56 changes: 56 additions & 0 deletions src/fundus/publishers/ls/lesotho_times.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import datetime
from typing import List, Optional

from lxml.etree import XPath

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


class LesothoTimesParser(ParserProxy):
class V1(BaseParser):
_paragraph_selector = XPath("//div[@class='entry-content']/p[text() or span]")
_subheadline_selector = XPath(
"//div[@class='entry-content']/p[not(text() or em) and strong[not(em)] and position()>4]"
)
_summary_selector = XPath("//div[@class='entry-content']/p[not(text()) and (strong[em] or em)]")

_author_selector = XPath(
"//div[@class='entry-content']/p[not(text() or em) and strong[not(em)] and position()<5]"
)

@attribute
def body(self) -> Optional[ArticleBody]:
return extract_article_body_with_selector(
self.precomputed.doc,
paragraph_selector=self._paragraph_selector,
subheadline_selector=self._subheadline_selector,
summary_selector=self._summary_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(generic_nodes_to_text(self._author_selector(self.precomputed.doc)))

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

@attribute
def images(self) -> List[Image]:
return image_extraction(
doc=self.precomputed.doc,
paragraph_selector=self._paragraph_selector,
image_selector=XPath("//div[@class='feature-postimg']/img"),
upper_boundary_selector=XPath("//header"),
)
170 changes: 170 additions & 0 deletions tests/resources/parser/test_data/ls/LesothoTimes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{
"V1": {
"authors": [
"Mohloai Mpesi"
],
"body": {
"summary": [],
"sections": [
{
"headline": [],
"paragraphs": [
"IN the heart of Lesotho, where tales of struggle and resilience are woven into the fabric of everyday life, one young lawyer stands as a beacon of hope.",
"Born in Roma and raised in Maseru, Advocate Mokitimi Tšosane, has transformed his personal tribulations into a passionate commitment to law and justice.",
"With a robust educational background and a deep understanding of the socio-economic challenges faced by his fellow Basotho, the young lawyer exemplifies all the aspirations and potential of a new generation of young lawyers in Lesotho.",
"The 32-year-old Adv Tšosane, was born on June 3rd 1993 in the small town of Roma in the outskirts of Maseru, to Mphutlane and ‘Matšosane Tšosane. After the tragic loss of his parents and eldest brother, all to Tuberculosis, he was raised by his grandmother in Matsoatlareng, Maseru.",
"“My grandmother was the shield against poverty,” he reflects, emphasizing the critical role she played in his upbringing.",
"Despite the hardships of growing up without his parents and having to rely on his grandmother for his livelihood, Adv Tšosane pursued education with evangelical fervour, eventually earning his LLB from the National University of Lesotho (NUL) after completing his secondary education at Lesotho High School.",
"“Education was not just a goal; it was a passion driven by my father, who worked tirelessly in the mines to provide for us,” Adv Tšosane shares.",
"His father’s relentless work ethic instilled in him a belief that success is not a matter of luck or chance but a product of perseverance and dedication.",
"He says his vision for a future free from the constraints of poverty propelled him into the legal field, where he aspires to fight for social justice.",
"The spark that ignited Adv Tšosane’s passion for law was kindled in his early years. Influenced by historical narratives and figures like Marcus Garvey and Malcolm X, he developed a deep-seated desire to confront injustices.",
"“The judges in my dreams were meant to curb the evil I saw in the world,” he explains, revealing his youthful conviction that law could be a tool for societal change.",
"Encouragement from mentors and peers solidified his resolve to pursue law. “I wouldn’t change my path if I had the chance,” he declares, demonstrating profound appreciation for the journey he has undertaken.",
"As a young lawyer, Adv Tšosane describes his career as still in its formative stages, echoing Robert Greene’s phases of mastery.",
"“I see myself as an experimenting apprentice, learning the unwritten rules and nuances of the legal culture,” he says.",
"His experiences thus far are commendable: he has made submissions at the African Commission, consulted for organizations such as Amnesty International, and trained parliamentarians alongside the University of Pretoria’s Centre for Human Rights.",
"Adv Tšosane’s passion lies particularly in Constitutional law, a field he believes is crucial for addressing the challenges faced by Basotho.",
"“A constitution should reflect the will of the people and establish accountability between citizens and the state,” he says, underscoring his belief in the importance of civic engagement in governance.",
"However, he also recognises that the Lesotho Constitution, while comprehensive in its civil rights provisions, struggles with the enforcement of socio-economic rights, which remain aspirational rather than actionable.",
"“The Constitution is not self-executing; its effectiveness relies on the consistent commitment of those in power to uphold its values,” Adv Tšosane argues.",
"He points out that while civil rights are clearly defined, socio-economic rights are often sidelined due to political indifference.",
"“With political will and proper interpretation, we can realize these rights for the people,” he emphasises, advocating for a proactive approach to constitutionality."
]
},
{
"headline": [
"Reforms"
],
"paragraphs": [
"In a country where the rule of law is both a constitutional promise and a daily struggle, Adv Tšosane is vocal about the ongoing constitutional reforms in Lesotho.",
"While many hail these long delayed reforms as necessary for progress, Adv Tšosane argues that they risk undermining the very foundations of the nation’s legal framework.",
"“As Lesotho grapples with constitutional amendments and their implications, the quest for genuine reform has become a contentious debate that resonates deeply with both the legal community and the broader society,” he says.",
"Lesotho’s Constitution, established in 1993, has faced numerous challenges, not least of which are recent attempts at reform.",
"Adv Tšosane articulates a pressing concern, that the current constitutional amendments, propelled by political actors, threaten to erase essential features of the Constitution under the guise of progress.",
"He refers to the concept of “constitutional dismemberment,” a term coined by legal scholar Richard Albert to describe how amendments can bypass key structural elements, ultimately jeopardizing the stability of the legal system.",
"“While the intention behind these reforms may seem sincere, the process has become a parody of what constitutional reform should be,” Adv Tšosane says, highlighting the abuse of the amendment process as “a means to fundamentally alter the Constitution without genuine public consent or discourse”.",
"The young lawyer points out that amendments often replace entire chapters and introduce new sections, blurring the line between constitutional amendments and ordinary legislative changes.",
"According to Adv Tšosane, his discomfort with these reforms is that they serve more as a political tool to please international donors than as genuine efforts to address the needs of the Basotho people.",
"Adv Tšosane notes with concern how the government has rushed legislative processes ahead of international summits, casting shadows on the legitimacy and transparency of these reforms.",
"“The reforms lack a clear agenda and seem disconnected from the pressing needs of the people,” he asserts."
]
},
{
"headline": [
"Words of wisdom"
],
"paragraphs": [
"According to Adv Tšosane, Advocate Karabo Karabo Mohau King’s Counsel (KC) once cautioned: “Constitutional amendment is indispensable to constitutional development but, like a double-edged sword, the process is capable of either helping or hurting a country’s project to build a constitutional state.”",
"This sentiment resonates with Adv Tosane, who believes the nation must first address the hearts and minds of the Basotho before venturing into extensive constitutional reforms."
]
},
{
"headline": [
"Flawed Approach"
],
"paragraphs": [
"Adv Tšosane acknowledges that while reform is necessary, the current approach is flawed. He emphasizes the need for a holistic, inclusive process that engages citizens and addresses the socio-political challenges facing Lesotho.",
"“It is not merely about rewriting laws; it is about fostering a culture of respect and adherence to the rule of law,” he says. The young lawyer draws attention to the systemic issues within the justice system, such as delays, underfunding, and political interference, which exacerbate the violations of human rights and public safety.",
"Despite these challenges, Adv Tšosane believes that the foundation for a robust legal framework exists. The dualist legal system, comprising both Roman-Dutch Law and Customary Law, offers flexibility and relevance.",
"However, he warns that recent retrogressive moves pose threats to the integrity of customary law.",
"Adv Tšosane voices concern over the potential dangers posed by Lesotho’s new Computer Crimes and Cyber Security Bill, 2023 to key sectors such as the media, civil organizations, and whistleblowers.",
"In a liberal democracy like Lesotho, whistleblowing plays a vital role in fighting corruption and exposing wrongdoing by those in power.",
"Adv Tšosane argues that whistleblowing is crucial not only for journalism, but also for law enforcement, commissions of inquiry, political investigations, and advocacy campaigns.",
"However, he warns that Sections 21, 24, and 26 of the bill are “vague, broad, and subject to abuse” in a way that could criminalize whistleblowing. “These sections, read together, effectively criminalize the communication and receipt of data, potentially leading to self-censorship in the publication of information,” he says.",
"Adv Tšosane points to the case of Julian Assange and WikiLeaks as a worrying precedent of the criminalization of whistleblowing and journalism.",
"According to Adv Tšosane, these sections unjustifiably limit the constitutional freedoms to receive and communicate ideas and information without interference, as enshrined in Section 14(1) of Lesotho’s Constitution.",
"While the lawyer acknowledges the need for the Computer Crimes and Cyber Security Bill, 2023 to address criminal activities in cyberspace and protect human rights and critical infrastructure online, he argues that the current drafting of the bill “opens it up for arbitrary use, misuse and abuse.”",
"He fears that the Bill has the potential to “shrink the media, civic and political space” in Lesotho, effectively trapping cyber users, especially dissidents."
]
},
{
"headline": [
"Constitutional literacy"
],
"paragraphs": [
"In addition to his concerns about the cyber bill, Adv Tšosane also highlights the importance of constitutional literacy and the need to protect Lesotho’s democracy from the growing threat of authoritarian populism. He suggests declaring every 2 April as “Constitution Day” and dedicating the entire month to constitutional education could help promote national pride, identity, and civic responsibility. The Constitution of Lesotho was introduced on 2 April 1993 when the country reverted back to constitutional democracy. In 1970 after ex-premier Leabua Jonathan lost that year’s elections, he rejected the outcome, suspended the constitution and ruled by decree for 16 years until he was overthrown by the army in 1986. The military junta would rule until 1993 when the country called its first democratic elections since 1970.",
"As Lesotho stands at the crossroads of constitutional reform, Mphutlane Tšosane’s insights shed light on the critical need for a thoughtful, inclusive approach to governance and law. The quest for justice and the protection of human rights must be paramount in any reform initiative.",
"Adv Tšosane’s sentiments resonate with the notion that young lawyers like him, are essential for shaping a more equitable legal landscape in Lesotho. This is because their energy and commitment to justice inspire hope in a system that often feels overshadowed by bureaucracy and archaic reasoning. His journey from a challenging childhood to a young legal advocate illustrates the potential for change in Lesotho’s socio-political landscape. His unwavering dedication to justice, coupled with a desire to uplift his community, sets a powerful precedent for future generations. “Every effort made to invest in education is an investment in the future,” he aptly summarizes, embodying the famous words of Nelson Mandela that education is the only tool with which to defeat poverty and depravation."
]
}
]
},
"images": [
{
"versions": [
{
"url": "https://lestimes.com/wp-content/uploads/2025/05/Mokitimi-Tsosane-250x150.jpg",
"query_width": null,
"size": {
"width": 250,
"height": 151
},
"type": "image/jpeg"
},
{
"url": "https://lestimes.com/wp-content/uploads/2025/05/Mokitimi-Tsosane-300x181.jpg",
"query_width": null,
"size": {
"width": 300,
"height": 182
},
"type": "image/jpeg"
},
{
"url": "https://lestimes.com/wp-content/uploads/2025/05/Mokitimi-Tsosane-556x336.jpg",
"query_width": null,
"size": {
"width": 556,
"height": 336
},
"type": "image/jpeg"
},
{
"url": "https://lestimes.com/wp-content/uploads/2025/05/Mokitimi-Tsosane-768x464.jpg",
"query_width": null,
"size": {
"width": 768,
"height": 465
},
"type": "image/jpeg"
},
{
"url": "https://lestimes.com/wp-content/uploads/2025/05/Mokitimi-Tsosane-980x593.jpg",
"query_width": null,
"size": {
"width": 980,
"height": 593
},
"type": "image/jpeg"
},
{
"url": "https://lestimes.com/wp-content/uploads/2025/05/Mokitimi-Tsosane-1536x929.jpg",
"query_width": null,
"size": {
"width": 1536,
"height": 929
},
"type": "image/jpeg"
},
{
"url": "https://lestimes.com/wp-content/uploads/2025/05/Mokitimi-Tsosane.jpg",
"query_width": null,
"size": {
"width": 1816,
"height": 1099
},
"type": "image/jpeg"
}
],
"is_cover": true,
"description": null,
"caption": null,
"authors": [],
"position": 222
}
],
"publishing_date": "2025-05-14 20:57:43+00:00",
"title": "From adversity to advocacy: a young lawyer's journey"
}
}
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/resources/parser/test_data/ls/meta.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"LesothoTimes_2025_05_23.html.gz": {
"url": "https://lestimes.com/from-adversity-to-advocacy-a-young-lawyers-journey/",
"crawl_date": "2025-05-23 00:04:42.557906"
}
}
Loading