New recipe for LWN by Oliver Niesner

This commit is contained in:
Kovid Goyal 2009-11-06 08:05:29 -07:00
parent 2f476f007a
commit 72ceac8117
2 changed files with 55 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

View File

@ -0,0 +1,55 @@
#!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''
lwn.net
'''
from calibre.web.feeds.news import BasicNewsRecipe
class LWN(BasicNewsRecipe):
title = u'lwn'
__author__ = 'Oliver Niesner'
description = 'Linux Weekly News'
oldest_article = 54
language = _('English')
max_articles_per_feed = 100
needs_subscription = True
language = 'en'
remove_javascript = True
simultaneous_downloads= 1
delay = 1
LOGIN = 'https://lwn.net/login'
def get_browser(self):
br = BasicNewsRecipe.get_browser()
if self.username is not None and self.password is not None:
br.open(self.LOGIN)
br.select_form(name='loginform')
br['Username'] = self.username
br['Password'] = self.password
br.submit()
return br
remove_tags = [
dict(name='td', attrs={'class':'LeftColumn'}),
dict(name='td', attrs={'class':'NavLink'}),
dict(name='div', attrs={'class':'FormattedComment'}),
dict(name='td', attrs={'class':'MCTopBanner'}),
dict(name='div', attrs={'class':'CommentBox'})
]
feeds = [
(u'lwn' , u'http://lwn.net/headlines/newrss' ),
]
def postprocess_html(self, soup, first):
for tag in soup.findAll(name=['table', 'tr', 'td']):
tag.name = 'div'
return soup
def print_version(self, url):
return url.replace ('rss', '?format=printable')