mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update Utrinski Vesnik
This commit is contained in:
parent
19581b8806
commit
cdca8936e2
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
__author__ = 'Darko Spasovski'
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2011, Darko Spasovski <darko.spasovski at gmail.com>'
|
__copyright__ = '2011, Darko Spasovski <darko.spasovski at gmail.com>'
|
||||||
'''
|
'''
|
||||||
@ -9,10 +10,11 @@ utrinski.com.mk
|
|||||||
import re
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
||||||
|
from calibre import browser
|
||||||
|
|
||||||
class UtrinskiVesnik(BasicNewsRecipe):
|
class UtrinskiVesnik(BasicNewsRecipe):
|
||||||
|
|
||||||
__author__ = 'Darko Spasovski'
|
|
||||||
INDEX = 'http://www.utrinski.com.mk/'
|
INDEX = 'http://www.utrinski.com.mk/'
|
||||||
title = 'Utrinski Vesnik'
|
title = 'Utrinski Vesnik'
|
||||||
description = 'Daily Macedonian newspaper'
|
description = 'Daily Macedonian newspaper'
|
||||||
@ -21,7 +23,6 @@ class UtrinskiVesnik(BasicNewsRecipe):
|
|||||||
remove_javascript = True
|
remove_javascript = True
|
||||||
publication_type = 'newspaper'
|
publication_type = 'newspaper'
|
||||||
category = 'news, Macedonia'
|
category = 'news, Macedonia'
|
||||||
oldest_article = 2
|
|
||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 100
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
@ -47,25 +48,29 @@ class UtrinskiVesnik(BasicNewsRecipe):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
soup = self.index_to_soup(self.INDEX)
|
|
||||||
feeds = []
|
feeds = []
|
||||||
for section in soup.findAll('a', attrs={'class':'WB_UTRINSKIVESNIK_TOCTitleBig'}):
|
# open main page
|
||||||
|
soup = self.index_to_soup(self.INDEX)
|
||||||
|
# find all anchors with class attribute equal to 'WB_UTRINSKIVESNIK_MainMenu'
|
||||||
|
for section in soup.findAll('a', attrs={'class':'WB_UTRINSKIVESNIK_MainMenu'}):
|
||||||
sectionTitle = section.contents[0].string
|
sectionTitle = section.contents[0].string
|
||||||
tocItemTable = section.findAllPrevious('table')[1]
|
sectionUrl = self.INDEX + section['href'].strip()
|
||||||
if tocItemTable is None: continue
|
# open the anchor link
|
||||||
|
raw = browser().open_novisit(sectionUrl).read()
|
||||||
|
sectionSoup = BeautifulSoup(raw)
|
||||||
|
# find all anchors with class attribute equal to 'WB_UTRINSKIVESNIK_ONLINEArticleTitle'
|
||||||
|
sectionArticles = sectionSoup.findAll('a', attrs={'class':'WB_UTRINSKIVESNIK_ONLINEArticleTitle'})
|
||||||
articles = []
|
articles = []
|
||||||
while True:
|
for sectionArticle in sectionArticles:
|
||||||
tocItemTable = tocItemTable.nextSibling
|
# article title = anchor's contents, article url = anchor's href
|
||||||
if tocItemTable is None: break
|
articleTitle = sectionArticle.contents[0].string.strip()
|
||||||
article = tocItemTable.findAll('a', attrs={'class': 'WB_UTRINSKIVESNIK_TocItem'})
|
articleUrl = self.INDEX + sectionArticle['href'].strip()
|
||||||
if len(article)==0: break
|
articleDate = datetime.datetime.today().strftime('%d.%m.%Y')
|
||||||
title = self.tag_to_string(article[0], use_alt=True).strip()
|
articles.append({'title': articleTitle, 'url':articleUrl, 'description':'', 'date': articleDate})
|
||||||
articles.append({'title': title, 'url':'http://www.utrinski.com.mk/' + article[0]['href'], 'description':'', 'date':''})
|
|
||||||
if articles:
|
if articles:
|
||||||
feeds.append((sectionTitle, articles))
|
feeds.append((sectionTitle, articles))
|
||||||
return feeds
|
return feeds
|
||||||
|
|
||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
datum = datetime.datetime.today().strftime('%d_%m_%Y')
|
datum = datetime.datetime.today().strftime('%d_%m_%Y')
|
||||||
return 'http://www.utrinski.com.mk/WBStorage/Files/' + datum + '.jpg'
|
return 'http://www.utrinski.com.mk/WBStorage/Files/' + datum + '.jpg'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user