| 1 |
#!/usr/bin/env python |
| 2 |
from calibre.web.feeds.news import BasicNewsRecipe, classes |
| 3 |
|
| 4 |
|
| 5 |
class PIB(BasicNewsRecipe): |
| 6 |
title = 'Press Information Bureau' |
| 7 |
language = 'en_IN' |
| 8 |
__author__ = 'unkn0wn' |
| 9 |
no_stylesheets = True |
| 10 |
use_embedded_content = False |
| 11 |
remove_attributes = ['style', 'height', 'width'] |
| 12 |
ignore_duplicate_articles = {'url'} |
| 13 |
description = ( |
| 14 |
'The Press Information Bureau (PIB) is the nodal agency of the Government of India' |
| 15 |
' to disseminate information to the print and electronic media on government policies,' |
| 16 |
' programmes, initiatives and achievements. Best downloaded at the end of the day!' |
| 17 |
) |
| 18 |
extra_css = ''' |
| 19 |
#ltrSubtitle{color:#404040;} |
| 20 |
blockquote{color:#404040;} |
| 21 |
.ReleaseDateSubHeaddateTime{font-style:italic; font-size:small;} |
| 22 |
''' |
| 23 |
|
| 24 |
masthead_url = 'https://tse3.mm.bing.net/th?id=OIP.4QE8KPl1dZ3_BoR3X92aqgHaIH' |
| 25 |
cover_url = 'https://static.pib.gov.in/WriteReadData/specificdocs/photo/2024/jun/ph2024624343601.jpg' |
| 26 |
|
| 27 |
keep_only_tags = [classes('innner-page-main-about-us-content-right-part')] |
| 28 |
remove_tags = [classes('ReleaseLang log_oo')] |
| 29 |
|
| 30 |
def parse_index(self): |
| 31 |
soup = self.index_to_soup('https://pib.gov.in/Allrel.aspx') |
| 32 |
feeds = [] |
| 33 |
for h3 in soup.findAll('h3'): |
| 34 |
secname = self.tag_to_string(h3) |
| 35 |
self.log(secname) |
| 36 |
articles = [] |
| 37 |
div = h3.findParent('li') |
| 38 |
for a in div.findAll('a', href=True): |
| 39 |
url = a['href'] |
| 40 |
if url.startswith('/'): |
| 41 |
url = 'https://pib.gov.in' + url |
| 42 |
title = self.tag_to_string(a) |
| 43 |
self.log('\t', title, '\n\t\t', url) |
| 44 |
articles.append({'title': title, 'url': url}) |
| 45 |
if articles: |
| 46 |
feeds.append((secname, articles)) |
| 47 |
return feeds |