calibre/recipes/ecogeek.recipe
Kovid Goyal 567040ee1e Perform PEP8 compliance checks on the entire codebase
Some bits of PEP 8 are turned off via setup.cfg
2016-07-29 21:25:17 +05:30

35 lines
1.1 KiB
Python

#!/usr/bin/env python2
__license__ = 'GPL v3'
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
'''
EcoGeek.org
'''
import os
from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ptempfile import PersistentTemporaryDirectory
class EcoGeek(BasicNewsRecipe):
title = 'EcoGeek'
__author__ = 'Darko Miletic'
description = 'EcoGeek - Technology for the Environment Blog Feed'
publisher = 'EcoGeek'
language = 'en'
no_stylesheets = True
def parse_index(self):
tdir = PersistentTemporaryDirectory('_ecogeek')
articles = []
soup = self.index_to_soup('http://feeds2.feedburner.com/EcoGeek')
for i, article in enumerate(soup.findAll('div', attrs={'class': 'article'})):
fname = os.path.join(tdir, '%d.html' % i)
with open(fname, 'wb') as f:
f.write(unicode(article).encode('utf-8'))
articles.append({
'title': self.tag_to_string(article.find('h2')),
'url': 'file://' + fname.replace(os.sep, '/'),
})
return [('EcoGeek', articles)]