2 more indentation fixes and fixed icons size
Before Width: | Height: | Size: 475 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1018 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1018 B |
@ -47,6 +47,6 @@ class KrytykaPolitycznaRecipe(BasicNewsRecipe):
|
|||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
for alink in soup.findAll('a'):
|
for alink in soup.findAll('a'):
|
||||||
if alink.string is not None:
|
if alink.string is not None:
|
||||||
tstr = alink.string
|
tstr = alink.string
|
||||||
alink.replaceWith(tstr)
|
alink.replaceWith(tstr)
|
||||||
return soup
|
return soup
|
||||||
|
@ -15,7 +15,7 @@ class naszdziennik(BasicNewsRecipe):
|
|||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
|
|
||||||
keep_only_tags =[dict(attrs = {'id' : 'article'})]
|
keep_only_tags =[dict(attrs = {'id' : 'article'})]
|
||||||
|
|
||||||
#definiujemy nową funkcje; musi zwracać listę feedów wraz z artykułami
|
#definiujemy nową funkcje; musi zwracać listę feedów wraz z artykułami
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
#adres do parsowania artykułów
|
#adres do parsowania artykułów
|
||||||
@ -28,7 +28,7 @@ class naszdziennik(BasicNewsRecipe):
|
|||||||
sections = []
|
sections = []
|
||||||
#deklaracja pierwszej sekcji jako pusty string
|
#deklaracja pierwszej sekcji jako pusty string
|
||||||
section = ''
|
section = ''
|
||||||
|
|
||||||
#pętla for, która analizuje po kolei każdy tag "news-article"
|
#pętla for, która analizuje po kolei każdy tag "news-article"
|
||||||
for item in soup.findAll(attrs = {'class' : 'news-article'}) :
|
for item in soup.findAll(attrs = {'class' : 'news-article'}) :
|
||||||
#w tagu "news-article szukamy pierwszego taga h4"
|
#w tagu "news-article szukamy pierwszego taga h4"
|
||||||
@ -51,11 +51,11 @@ class naszdziennik(BasicNewsRecipe):
|
|||||||
#jako tytuł użyty będzie tekst pomiędzy tagami <a>
|
#jako tytuł użyty będzie tekst pomiędzy tagami <a>
|
||||||
article_title = self.tag_to_string(article_a)
|
article_title = self.tag_to_string(article_a)
|
||||||
#a data będzie tekstem z pierwszego taga h4 znalezionego w tagu title-datetime
|
#a data będzie tekstem z pierwszego taga h4 znalezionego w tagu title-datetime
|
||||||
article_date = self.tag_to_string(article_title_datetime.find('h4'))
|
article_date = self.tag_to_string(article_title_datetime.find('h4'))
|
||||||
#zebrane elementy dodajemy do listy zadeklarowanej w linijce 44
|
#zebrane elementy dodajemy do listy zadeklarowanej w linijce 44
|
||||||
articles[section].append( { 'title' : article_title, 'url' : article_url, 'date' : article_date })
|
articles[section].append( { 'title' : article_title, 'url' : article_url, 'date' : article_date })
|
||||||
#po dodaniu wszystkich artykułów dodajemy sekcje do listy feedów, korzystając z list sekcji znajdujących się w słowniku
|
#po dodaniu wszystkich artykułów dodajemy sekcje do listy feedów, korzystając z list sekcji znajdujących się w słowniku
|
||||||
for section in sections:
|
for section in sections:
|
||||||
feeds.append((section, articles[section]))
|
feeds.append((section, articles[section]))
|
||||||
#zwracamy listę feedów, której parsowaniem zajmie się calibre
|
#zwracamy listę feedów, której parsowaniem zajmie się calibre
|
||||||
return feeds
|
return feeds
|
||||||
|