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 indian publisher Bhaskar #605

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions docs/supported_publishers.md
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,21 @@
</tr>
</thead>
<tbody>
<tr>
<td>
<code>Bhaskar</code>
</td>
<td>
<div>Dainik Bhaskar</div>
</td>
<td>
<a href="https://www.bhaskar.com/">
<span>www.bhaskar.com</span>
</a>
</td>
<td>&#160;</td>
<td>&#160;</td>
</tr>
<tr>
<td>
<code>TimesOfIndia</code>
Expand Down
10 changes: 9 additions & 1 deletion src/fundus/publishers/ind/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fundus.publishers.base_objects import Publisher, PublisherGroup
from fundus.publishers.ind.bhaskar import BhaskarParser
from fundus.publishers.ind.times_of_india import TimesOfIndiaParser
from fundus.scraping.url import NewsMap, RSSFeed
from fundus.scraping.url import NewsMap, RSSFeed, Sitemap


class IND(metaclass=PublisherGroup):
Expand All @@ -15,3 +16,10 @@ class IND(metaclass=PublisherGroup):
RSSFeed("https://timesofindia.indiatimes.com/rssfeedmostrecent.cms"),
],
)

Bhaskar = Publisher(
name="Dainik Bhaskar",
domain="https://www.bhaskar.com/",
parser=BhaskarParser,
sources=[NewsMap("https://www.bhaskar.com/sitemaps-v1--sitemap-google-news-index.xml")],
)
40 changes: 40 additions & 0 deletions src/fundus/publishers/ind/bhaskar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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,
generic_topic_parsing,
)


class BhaskarParser(ParserProxy):
class V1(BaseParser):
_paragraph_selector = XPath("//article //p[text()]")
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are some articles that have subheadlines, such as this one. It is clearer in the HTML:

<p class="c4fb714d" style="word-break:break-word">सब इंस्पेक्टर (SI) भर्ती पेपर लीक मामले में राजस्थान लोक सेवा आयोग (RPSC) एक बार फिर विवादों में है। एसओजी ने RPSC के पूर्व सदस्य रामू राम राईका काे गिरफ्तार किया है। राईका ने एग्जाम से 7 दिन पहले बेटी शोभा और बेटे देवेश को पेपर दे दिया था। पुलिस ने</p><div class="a5993508 paywallBlockedContent"><div>.</div><p class="" style="word-break:break-word">रामू राम राईका 4 जुलाई 2018 से लेकर 4 जुलाई 2022 तक RPSC में सदस्य रहा था। RPSC के पूर्व सदस्य बाबूलाल कटारा को भी सीनियर टीचर भर्ती पेपर लीक में एसओजी गिरफ्तार कर चुकी है।</p><p class="" style="word-break:break-word">इससे पहले भी सीनियर टीचर भर्ती, लाइब्रेरियन भर्ती, जेईएन पेपर, हाईकोर्ट एलडीसी भर्ती, लेक्चरर भर्ती में भी RPSC विवादों में आ चुकी है। बड़ा सवाल है कि तमाम सुरक्षा के दावों के बीच RPSC से पेपर लीक कैसे हो जाते हैं?</p><p class="" style="word-break:break-word">इस सवाल का जवाब जानने के लिए भास्कर ने RPSC के पूर्व सदस्यों से बात की। उन्होंने पहचान उजागर न करने की शर्त पर पेपर बनने से सेंटर तक पहुंचने की पूरी प्रक्रिया बताई। साथ ही ये भी बताया कि कहां-कहां से पेपर लीक हो सकता है।</p><p class="" style="word-break:break-word"><strong><i>पढ़िए पूरी रिपोर्ट…</i></strong></p><div class="f3e032cb"><picture class="c62bd949" style="visibility:visible"><source media="(max-width: 768px)" type="image/webp" srcset="https://images.bhaskarassets.com/webp/thumb/360x0/web2images/521/2024/09/02/whatsapp-image-2024-09-02-at-201350_1725288249.jpeg"><source media="(min-width: 768px)" type="image/webp" srcset="https://images.bhaskarassets.com/webp/thumb/512x0/web2images/521/2024/09/02/whatsapp-image-2024-09-02-at-201350_1725288249.jpeg"><img width="512" height="399" src="https://images.bhaskarassets.com/web2images/521/2024/09/02/whatsapp-image-2024-09-02-at-201350_1725288249.jpeg" alt="" loading="lazy" class="f97587ba"></picture></div><div class="f46ba790"><span></span></div><p class="" style="word-break:break-word"><strong>सवाल : किस विभाग में कितने पदों पर भर्ती होगी, ये कौन तय करता है?</strong></p><p class="" style="word-break:break-word"><strong>जवाब : </strong>किसी विभाग में अगर पद खाली होते हैं तो उसकी सूची सरकार को भेजी जाती है। इसके बाद सरकार खाली पदों के हिसाब से भर्ती कराने की प्रक्रिया के लिए RPSC को पत्र लिखती है। कितने पदों पर भर्ती की जानी है, उसका आकलन किया जाता है। सरकार से खाली पदों पर भर्ती कराए जाने का पूरा प्रोसेस होने के बाद RPSC ही पदों की विज्ञप्ति जारी करवाती है।</p><p class="" style="word-break:break-word"><strong>सवाल : भर्ती परीक्षा का पेपर कौन सेट करता है?</strong></p><p class="" style="word-break:break-word"><strong>जवाब :</strong> एग्जाम की डेट डिसाइड होने के बाद बारी आती है पेपर तैयार कराने की। RPSC में पेपर बनाने का काम पूरी गोपनीयता से किया जाता है। पेपर बनाने से पहले यह तय किया जाता है कि पेपर बनाने वाले प्रोफेसर का सिलेक्शन कौन करेगा?</p><p class="" style="word-break:break-word">आरपीएससी में पेपर बनवाने का काम अध्यक्ष या मेंबर करते हैं। पेपर बनाने वाले प्रोफेसर का सिलेक्शन आयोग या बोर्ड के नियम और शर्तों के अनुसार होता है। RPSC अध्यक्ष ही तय करता है कि भर्ती परीक्षा के कितने पेपर सेट बनवाएंगे।</p><div class="f3e032cb"><picture class="c62bd949" style="visibility:visible"><source media="(max-width: 768px)" type="image/webp" srcset="https://images.bhaskarassets.com/webp/thumb/360x0/web2images/521/2024/09/02/cover-1_1725288918.jpg"><source media="(min-width: 768px)" type="image/webp" srcset="https://images.bhaskarassets.com/webp/thumb/512x0/web2images/521/2024/09/02/cover-1_1725288918.jpg"><img width="730" height="548" src="https://images.bhaskarassets.com/web2images/521/2024/09/02/cover-1_1725288918.jpg" alt="एसओजी ने पेपर लीक मामले में RPSC के पूर्व सदस्य रामू राम राईका काे गिरफ्तार किया है।" loading="lazy" class="f97587ba"></picture></div><div class="f46ba790"><span>एसओजी ने पेपर लीक मामले में RPSC के पूर्व सदस्य रामू राम राईका काे गिरफ्तार किया है।</span></div><p class="" style="word-break:break-word"><strong>सवाल : कौनसा पेपर फाइनल रहेगा, इसका फैसला कैसे होता है?</strong></p><p class="" style="word-break:break-word"><strong>जवाब : </strong>किसी भी भर्ती परीक्षा के लिए 3 से 5 प्रोफेसर से अलग-अलग पेपर बनवाए जाते हैं। प्रोफेसर के सिलेक्शन को भी पूरी तरह से गोपनीय रखा जाता है। जिसके बारे में केवल आयोग के अध्यक्ष को ही पता होता है। प्रोफेसर से पेपर बनवाने से पहले RPSC उनसे गोपनीयता और विश्वसनीयता का एफिडेविट लेती है।</p><p class="" style="word-break:break-word">RPSC के पास पेपर सेट आने के बाद अध्यक्ष तय करता है कि पांचों पेपर से मिलाकर एक पेपर सेट बनाया जाए या उन पेपर में से कोई एक पेपर फाइनल किया जाए। ज्यादातर पेपर सेट से सवालों को मिक्स करके एक फाइनल पेपर बनाया जाता है।</p><div class="f3e032cb"><picture class="c62bd949" style="visibility:visible"><source media="(max-width: 768px)" type="image/webp" srcset="https://images.bhaskarassets.com/webp/thumb/360x0/web2images/521/2024/09/02/02-rr_1725290219.jpg"><source media="(min-width: 768px)" type="image/webp" srcset="https://images.bhaskarassets.com/webp/thumb/512x0/web2images/521/2024/09/02/02-rr_1725290219.jpg"><img width="730" height="697" src="https://images.bhaskarassets.com/web2images/521/2024/09/02/02-rr_1725290219.jpg" alt="" loading="lazy" class="f97587ba"></picture></div><div class="f46ba790"><span></span></div><p class="" style="word-break:break-word"><strong>सवाल : पेपर कहां छपेंगे, ये फैसला कौन और कैसे करता है?</strong></p><p class="" style="word-break:break-word"><strong>जवाब : </strong>RPSC के नियमों के अनुसार पेपर सेट फाइनल होने के बाद प्रिंटिंग प्रेस का चयन करने के लिए गोपनीय टेंडर निकाला जाता है। गोपनीयता के कारण इसका ओपन टेंडर नहीं निकाला जाता है। टेंडर के बारे में केवल अध्यक्ष को ही पता होता है।</p><p class="" style="word-break:break-word">अध्यक्ष ही प्रिंटिंग प्रेस का चयन करता है। प्रेस को सील बंद लिफाफे में पेपर सेट दिया जाता है। प्रिंटिंग प्रेस प्रदेश से बाहर भी हो सकती है। प्रिंटिंग प्रेस का चयन उसकी वैल्यू और पूर्व के रिकॉर्ड के हिसाब से किया जाता है।</p><p class="" style="word-break:break-word">इसमें भी पूरी तरह से सिक्योरिटी का ध्यान रखा जाता है। पेपर छापते समय प्रिंटिंग प्रेस में कर्मचारियों की तलाशी ली जाती है। नजरबंद करके ही पूरे पेपर छपवाए जाते हैं। यहीं से सील बंद लिफाफों में पेपर पहुंचाए जाते हैं।</p><p class="" style="word-break:break-word"><strong>सवाल : क्या प्रिंटिंग प्रेस से पेपर लीक हो सकता है?</strong></p><p class="" style="word-break:break-word"><strong>जवाब :</strong> प्रिंटिंग प्रेस से पेपर आउट होने की पूरी आशंका रहती है। नकल गिरोह के लोग प्रिंटिंग प्रेस का पता लगाकर कर्मचारियों से सेटिंग कर सकते हैं। उन्हें मोटा लालच देकर मोबाइल पर ही पूरा पेपर सेट मंगवा सकते हैं। प्रिंटिंग प्रेस में छपने के दौरान ही पेपर बाहर आ सकता है। पूर्व चेयरमैन हबीब खां गौरान अपनी बेटी के लिए पेपर लेने प्रिंटिंग प्रेस तक पहुंच गए थे। तब आरएएस और आरजेएस परीक्षा काफी विवादों में रही थी।</p><div class="f3e032cb"><picture class="c62bd949" style="visibility:visible"><source media="(max-width: 768px)" type="image/webp" srcset="https://images.bhaskarassets.com/webp/thumb/360x0/web2images/521/2024/09/02/k-ffp-generals2-1200x676-1986d4da-9cb6-11e9-9859-f_1725288499.jpeg"><source media="(min-width: 768px)" type="image/webp" srcset="https://images.bhaskarassets.com/webp/thumb/512x0/web2images/521/2024/09/02/k-ffp-generals2-1200x676-1986d4da-9cb6-11e9-9859-f_1725288499.jpeg"><img width="1146" height="646" src="https://images.bhaskarassets.com/web2images/521/2024/09/02/k-ffp-generals2-1200x676-1986d4da-9cb6-11e9-9859-f_1725288499.jpeg" alt="प्रिंटिंग प्रेस के कर्मचारियों से भी मिलीभगत कर पेपर लीक की आशंका रहती है। (फोटो प्रतीकात्मक)" loading="lazy" class="f97587ba"></picture></div><div class="f46ba790"><span>प्रिंटिंग प्रेस के कर्मचारियों से भी मिलीभगत कर पेपर लीक की आशंका रहती है। (फोटो प्रतीकात्मक)</span></div><p class="" style="word-break:break-word"><strong>सवाल : छपने के बाद एग्जाम होने तक पेपर की सिक्योरिटी कैसे की जाती है?</strong></p><p class="" style="word-break:break-word"><strong>जवाब : </strong>प्रिंटिंग प्रेस से छपने के बाद पेपर सील बंद लिफाफों में पैक किए जाते हैं। उन पर सीरियल नंबर प्रिंट किए जाते हैं। इसी आधार पर प्रिंटिंग प्रेस से पेपर निकलने के बाद RPSC उन्हें स्ट्रॉन्ग रूम में रखवा देती है।</p><p class="" style="word-break:break-word">पेपर सील बंद लिफाफों में लोहे के बॉक्स में बंद करके दो लॉक लगाए जाते हैं। जिनकी चाबी अलग-अलग अधिकारियों को दी जाती है। दोनों चाबी से लॉक खोलकर ही बॉक्स को खोला जाता है।</p><p class="" style="word-break:break-word">पेपर स्ट्राॅन्ग रूम से लाने से लेकर बॉक्स में रखने तक की पूरी प्रक्रिया की वीडियोग्राफी कराई जाती है। स्ट्राॅन्ग रूम के बाहर भी सीसीटीवी कैमेर लगाए जाते हैं। इतना ही नहीं, स्ट्राॅन्ग रूम से लेकर सेंटरों तक पहुंचाने की पूरी प्रक्रिया में भी वीडियोग्राफी की जाती है।</p><p class="" style="word-break:break-word"><strong>सवाल : पेपर स्ट्रॉन्ग रूम से सेंटर तक कैसे पहुंचाए जाते हैं?</strong></p><p class="" style="word-break:break-word"><strong>जवाब : </strong>स्ट्रॉन्ग रूम से पेपर परीक्षा होने से कुछ घंटे पहले ही सेंटर तक पहुंचाए जाते हैं। जीपीएस लगी गाड़ियों से ही पेपर ले जाते हैं। इन गाड़ियों में भी कैमरे लगे होते हैं। सीसीटीवी कैमरे की निगरानी में ही सेंटर में पेपर रखवाए जाते हैं। कमरों को लॉक किया जाता है। इन रूम के बाहर पुलिसकर्मियों की डयूटी लगाई जाती है।</p><div class="f3e032cb"><picture class="c62bd949" style="visibility:visible"><source media="(max-width: 768px)" type="image/webp" srcset="https://images.bhaskarassets.com/webp/thumb/360x0/web2images/521/2024/09/02/whatsapp-image-2024-09-02-at-201529_1725288360.jpeg"><source media="(min-width: 768px)" type="image/webp" srcset="https://images.bhaskarassets.com/webp/thumb/512x0/web2images/521/2024/09/02/whatsapp-image-2024-09-02-at-201529_1725288360.jpeg"><img width="512" height="384" src="https://images.bhaskarassets.com/web2images/521/2024/09/02/whatsapp-image-2024-09-02-at-201529_1725288360.jpeg" alt="REET-2021 में जयपुर स्थित शिक्षा संकुल के स्ट्रॉन्ग रूम से सब ट्रेजरी भेजते समय आरोपियों ने रास्ते में ही लिफाफा खोलकर पेपर निकाला था।" loading="lazy" class="f97587ba"></picture></div><div class="f46ba790"><span>REET-2021 में जयपुर स्थित शिक्षा संकुल के स्ट्रॉन्ग रूम से सब ट्रेजरी भेजते समय आरोपियों ने रास्ते में ही लिफाफा खोलकर पेपर निकाला था।</span></div><p class="" style="word-break:break-word"><strong>सवाल : क्या स्ट्रॉन्ग रूम में पेपर पूरी तरह सुरक्षित रहते हैं?</strong></p><p class="" style="word-break:break-word"><strong>जवाब : </strong>नहीं, वहां भी पेपर लीक की आशंका रहती है। कॉन्स्टेबल भर्ती का पेपर झोटवाड़ा में दिवाकर स्कूल के स्ट्रॉन्ग रूम से ही आउट हुआ था। उन्होंने स्ट्रॉन्ग रूम में रखे बॉक्स को ही काट कर पेपर निकाल लिया था। पूर्व मेंबर बाबूलाल कटारा भी पेपर लेने स्ट्रॉन्ग रूम में पहुंच गया था।</p><p class="" style="word-break:break-word">इसके अलावा REET-2021 में जयपुर स्थित शिक्षा संकुल के स्ट्रॉन्ग रूम से पेपर आउट हो गया था। पेपर शिक्षा संकुल के स्ट्रॉन्ग रूम से सब ट्रेजरी भेजते समय आरोपियों ने रास्ते में ही लिफाफा खोलकर निकाल लिया था।</p><p class="" style="word-break:break-word"><strong>सवाल : क्या सेंटर पर भी पेपर लीक का खतरा रहता है‌?</strong></p><p class="" style="word-break:break-word"><strong>जवाब : </strong>परीक्षा सेंटर पर ही सबसे ज्यादा पेपर लीक होने की संभावना रहती है। पेपर सेंटर में पहुंचने पर गिरोह के लोग सक्रिय रहते हैं। स्कूल के टीचरों और कर्मचारियों को लालच देकर सेटिंग कर सकते हैं। यूनिक भांबू और शेर सिंह मीणा ने सेंटरों से ही पेपर आउट कराए थे।</p><p class="" style="word-break:break-word"><strong>यह खबर भी पढ़ें...</strong></p><p class="" style="word-break:break-word"><strong>

You might have to copy and paste it out of here. But there are some sections like this one:
<p class="" style="word-break:break-word"><strong>सवाल : पेपर कहां छपेंगे, ये फैसला कौन और कैसे करता है?</strong></p>
that seem to be a subheadline. The text translates to question: Who decides where the papers will be printed and how?, which does suggest it could be a subheadline as well. At the moment lines like this are not parsed at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed the text() constraint from p again, so those should be parsed again. Additionally, I think there is no reliable way to distinguish between subheadlines and bloat, and thus no way to differentiate between paragraphs and subheadings. I will add them as simple paragraphs.


@attribute
def body(self) -> ArticleBody:
return extract_article_body_with_selector(
doc=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.ld.bf_search("headline")

@attribute
def topics(self) -> List[str]:
return generic_topic_parsing(self.precomputed.ld.bf_search("keywords"))
27 changes: 27 additions & 0 deletions tests/resources/parser/test_data/ind/Bhaskar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"V1": {
"authors": [
"दैनिक भास्कर"
],
"body": {
"summary": [],
"sections": [
{
"headline": [],
"paragraphs": [
"मैनपुरी में एक ट्रक ने बाइक सवार को रौंद दिया। हादसे में पति-पत्नी और बच्चे की मौत हो गई। हादसे के बाद ट्रक ड्राइवर मौके से फरार हो गया। मौके पर भीड़ जुट गई। लोगों ने पुलिस को सूचना दी। पुलिस ने शवों को पोस्टमॉर्टम के लिए भेज दिया।",
"सूचना पर पहुंचे परिजनों में कोहराम मच गया। हादसा सदर कोतवाली क्षेत्र में स्थित राधा रमन रोड पेट्रोल पंप के पास हुआ। मृतक की पहचान फर्रुखाबाद के शमशाबाद थाना क्षेत्र निवासी आजम के रूप में हुई। उनकी पत्नी और बेटा भी गाड़ी पर पीछे बैठे थे।",
"मौके पर पहुंच परिजनों ने बताया कि आजम अपनी बाइक पर अपनी पत्नी और बच्चे को लेकर मैनपुरी में निर्माणाधीन कोल्ड स्टोरेज में मजदूरी करने के लिए अपने घर से निकले थे। जैसे ही वह राधा रमन रोड पेट्रोल पंप के सामने पहुंचे। वैसे ही पीछे से आ रहे तेज रफ्तार डंपर ट्रक ने उनकी बाइक को रौंद दिया।",
"मौके पर ही तीनों की मौत हो गई। परिजन ने आगे बताया कि आजम और उसकी पत्नी एक साथ मजदूरी करते थे। इसी से उनका घर चलता था। आज अपने बेटे को भी साथ ले जा रहे थे।"
]
}
]
},
"publishing_date": "2024-09-03 20:46:01+05:30",
"title": "सड़क हादसे में पति-पत्नी सहित बच्चे की मौत: मैनपुरी में अनियंत्रित ट्रक ने रौंदा, बाइक से तीनों जा रहे थे",
"topics": [
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would also consider filtering topics containting news

"bhaskar news",
"mainpuri news"
]
}
}
Binary file not shown.
4 changes: 4 additions & 0 deletions tests/resources/parser/test_data/ind/meta.info
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"Bhaskar_2024_09_03.html.gz": {
"url": "https://www.bhaskar.com/local/uttar-pradesh/mainpuri/news/husband-and-wife-along-with-their-child-died-in-a-road-accident-133585351.html",
"crawl_date": "2024-09-03 17:16:12.570644"
},
"TimesOfIndia_2024_09_02.html.gz": {
"url": "https://timesofindia.indiatimes.com/world/pakistan/anti-terror-op-turns-sinister-pakistani-netizens-being-walled-off-as-army-raises-spectre-of-digital-terrorism/articleshow/112898501.cms",
"crawl_date": "2024-09-02 23:12:24.525515"
Expand Down