Cleanup previous PR
We cant rename recipe files as that will break users Fetch news subscriptions to the renamed recipe. Also optimize the recipe icons and move them into the icons subfolder. Apply some pep8 cleanup.
Before Width: | Height: | Size: 1.2 KiB |
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from calibre.web.feeds.recipes import BasicNewsRecipe
|
from calibre.web.feeds.recipes import BasicNewsRecipe
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
|
|
||||||
class Volkskrant(BasicNewsRecipe):
|
class Volkskrant(BasicNewsRecipe):
|
||||||
title = 'Dilema'
|
title = 'Dilema'
|
||||||
@ -42,9 +42,9 @@ class Volkskrant(BasicNewsRecipe):
|
|||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
homepage_url = 'https://www.dilema.ro/'
|
homepage_url = 'https://www.dilema.ro/'
|
||||||
soup = self.index_to_soup(homepage_url)
|
soup = self.index_to_soup(homepage_url)
|
||||||
|
|
||||||
articles = []
|
articles = []
|
||||||
|
|
||||||
# .banner-container
|
# .banner-container
|
||||||
banner_container = soup.find('div', attrs={'class': 'banner-container'})
|
banner_container = soup.find('div', attrs={'class': 'banner-container'})
|
||||||
container = banner_container.find('h5')
|
container = banner_container.find('h5')
|
||||||
@ -59,7 +59,7 @@ class Volkskrant(BasicNewsRecipe):
|
|||||||
content=''
|
content=''
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# .homepage_builder_3grid_post
|
# .homepage_builder_3grid_post
|
||||||
containers = soup.findAll('div', attrs={'class': 'homepage_builder_3grid_post'})
|
containers = soup.findAll('div', attrs={'class': 'homepage_builder_3grid_post'})
|
||||||
for container in containers:
|
for container in containers:
|
||||||
@ -99,9 +99,9 @@ class Volkskrant(BasicNewsRecipe):
|
|||||||
body.clear()
|
body.clear()
|
||||||
body.append(img)
|
body.append(img)
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
url = 'https://www.dilema.ro/coperta-saptaminii/'
|
url = 'https://www.dilema.ro/coperta-saptaminii/'
|
||||||
soup = self.index_to_soup(url)
|
soup = self.index_to_soup(url)
|
||||||
img = soup.find(attrs={'id': 'main-carousel'}).find('img')
|
img = soup.find(attrs={'id': 'main-carousel'}).find('img')
|
||||||
return url + img.attrs['src']
|
return url + img.attrs['src']
|
||||||
|
BIN
recipes/icons/dilema.png
Normal file
After Width: | Height: | Size: 767 B |
BIN
recipes/icons/internazionale.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
recipes/icons/parool.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
recipes/icons/revista22.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 1.6 KiB |
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from calibre.web.feeds.recipes import BasicNewsRecipe
|
from calibre.web.feeds.recipes import BasicNewsRecipe
|
||||||
|
|
||||||
|
|
||||||
class Volkskrant(BasicNewsRecipe):
|
class Volkskrant(BasicNewsRecipe):
|
||||||
title = 'Internazionale'
|
title = 'Internazionale'
|
||||||
__author__ = 'Cristi Ghera'
|
__author__ = 'Cristi Ghera'
|
||||||
@ -32,11 +33,11 @@ class Volkskrant(BasicNewsRecipe):
|
|||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
ignore_duplicate_articles = {'url'}
|
ignore_duplicate_articles = {'url'}
|
||||||
|
|
||||||
current_number_url = "https://www.internazionale.it/sommario"
|
current_number_url = "https://www.internazionale.it/sommario"
|
||||||
home_url = "https://www.internazionale.it"
|
home_url = "https://www.internazionale.it"
|
||||||
cover_url = None
|
cover_url = None
|
||||||
|
|
||||||
def extract_article(self, article):
|
def extract_article(self, article):
|
||||||
url = article.find('a')['href']
|
url = article.find('a')['href']
|
||||||
if url[0] == '/':
|
if url[0] == '/':
|
||||||
@ -74,16 +75,16 @@ class Volkskrant(BasicNewsRecipe):
|
|||||||
sections.append(current_section)
|
sections.append(current_section)
|
||||||
current_section = (self.tag_to_string(container), [])
|
current_section = (self.tag_to_string(container), [])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if 'masonry-items' in container['class']:
|
if 'masonry-items' in container['class']:
|
||||||
for article in container.findAll('div', {'class': 'abstract-article'}):
|
for article in container.findAll('div', {'class': 'abstract-article'}):
|
||||||
current_section[1].append(self.extract_article(article))
|
current_section[1].append(self.extract_article(article))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if 'abstract-article' in container['class']:
|
if 'abstract-article' in container['class']:
|
||||||
current_section[1].append(self.extract_article(container))
|
current_section[1].append(self.extract_article(container))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# print(container['class'])
|
# print(container['class'])
|
||||||
if current_section:
|
if current_section:
|
||||||
sections.append(current_section)
|
sections.append(current_section)
|
||||||
@ -112,6 +113,6 @@ class Volkskrant(BasicNewsRecipe):
|
|||||||
# if self.browser.cookiejar:
|
# if self.browser.cookiejar:
|
||||||
# self.browser.cookiejar.clear()
|
# self.browser.cookiejar.clear()
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
return self.cover_url
|
return self.cover_url
|
||||||
|
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 12 KiB |