Update IEEE Spectrum

This commit is contained in:
Kovid Goyal 2014-08-01 00:51:47 +05:30
parent 4e902d18d0
commit 384b6b924a

View File

@ -1,63 +1,45 @@
__license__ = 'GPL v3'
__copyright__ = '2010, Franco Venturi <fventuri at comcast.net>'
''' '''
spectrum.ieee.org Fetch RSS-Feeds http://spectrum.ieee.org via feedburner.com
''' '''
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
from string import capwords
from urlparse import urljoin
class IEEESpectrum(BasicNewsRecipe): class BasicUserRecipe1406801106(BasicNewsRecipe):
title = 'IEEE Spectrum' title = u'IEEE-Spectrum Online'
__author__ = 'Franco Venturi' description = u'The world\'s largest professional association dedicated to advancing technological innovation and excellence for the benefit of humanity'
description = 'Electronics News from IEEE' publisher = u'IEEE.org'
publisher = 'IEEE' __author__ = 'Armin Geller'
category = 'news, electronics, IT, computer science' category = 'news, electronics, IT, computer science'
oldest_article = 32 # Version: 1.0 AGe 2014-07-31
language = 'en'
encoding = 'utf-8'
oldest_article = 7
max_articles_per_feed = 100 max_articles_per_feed = 100
no_stylesheets = True remove_empty_feeds = True
use_embedded_content = False auto_cleanup = True
language = 'en'
index = 'http://spectrum.ieee.org/magazine/'
masthead_url = 'http://spectrum.ieee.org/images/logo_hdr.png'
remove_javascript = True feeds = [
remove_tags = [dict(name={'script':True, 'object':True})] (u'IEEE Spectrum Recent Content',
remove_attributes = ['height','width','alt'] u'http://feeds.feedburner.com/IeeeSpectrum?format=xml'),
keep_only_tags = [dict(attrs={'class': {'artSctn':True, 'artTitle':True, 'dekTitle': True}}), dict(attrs={'id':'artBody'})] (u' - Aerospace',
u'http://feeds.feedburner.com/IeeeSpectrumAerospace?format=xml'),
(u' - Biomedical',
def parse_index(self): u'http://feeds.feedburner.com/IeeeSpectrumBiomedical?format=xml'),
soup = self.index_to_soup(self.index) (u' - Computing',
img = soup.find('img', image='cover.gif', src=True) u'http://feeds.feedburner.com/IeeeSpectrumComputing?format=xml'),
if img is not None: (u' - Consumer Electronics',
self.cover_url = 'http://spectrum.ieee.org'+img['src'] u'http://feeds.feedburner.com/IeeeSpectrumConsumer?format=xml'),
(u' - Energy',
content = soup.find(id='gnrlContent') u'http://feeds.feedburner.com/IeeeSpectrumEnergy?format=xml'),
title = content.find(attrs={'class':'style4'}).string.strip() (u' - GreenTech',
date = ' '.join(title.split()[0:2]) u'http://feeds.feedburner.com/IeeeSpectrumGreenTech?format=xml'),
self.timefmt = ' [' + date + ']' (u' - Robotics',
contents = [] u'http://feeds.feedburner.com/IeeeSpectrumRobotics?format=xml'),
for tag in content.findAll(attrs={'class': {'style2':True, 'lstngTitle':True, 'lstngBody': True}}): (u' - Semiconductors',
if tag['class'] == 'style2': u'http://feeds.feedburner.com/IeeeSpectrumSemiconductors?format=xml'),
contents.append((capwords(tag.renderContents().strip()), [])) (u' - Telecom',
elif tag['class'] == 'lstngTitle': u'http://feeds.feedburner.com/IeeeSpectrumTelecom?format=xml'),
url = urljoin(self.index, tag.findPrevious('a')['href']) + '/0' (u' - At Work',
contents[-1][1].append({'title': tag.renderContents().strip(), u'http://feeds.feedburner.com/IeeeSpectrumAtWork?format=xml'),
'url': url, (u' - Geek Life',
'date': date, u'http://feeds.feedburner.com/IeeeSpectrumGeekLife?format=xml'),
'description': '', ]
'content': ''
})
elif tag['class'] == 'lstngBody':
contents[-1][1][-1]['description'] = tag.renderContents().strip()
return contents
def preprocess_html(self, soup):
for a in soup.findAll('a'):
if not a['href'].lower().startswith('http'):
a['href'] = urljoin(self.index, a['href'])
return soup