~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/web/feeds/recipes/recipe_noaa.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20090730124941-kviipg9ypwgppulc
Tags: upstream-0.6.3+dfsg
ImportĀ upstreamĀ versionĀ 0.6.3+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env  python
 
2
 
 
3
__license__   = 'GPL v3'
 
4
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
 
5
'''
 
6
noaa.com
 
7
'''
 
8
 
 
9
from calibre.web.feeds.news import BasicNewsRecipe
 
10
from calibre.ebooks.BeautifulSoup import Tag
 
11
 
 
12
class NOAA(BasicNewsRecipe):
 
13
    title                  = 'NOAA Online'
 
14
    __author__             = 'Darko Miletic'
 
15
    description            = 'NOAA'
 
16
    publisher              = 'NOAA'
 
17
    category               = 'news, science, US, ocean'
 
18
    oldest_article         = 15
 
19
    max_articles_per_feed  = 100
 
20
    no_stylesheets         = True
 
21
    use_embedded_content   = False
 
22
    simultaneous_downloads = 1
 
23
    encoding               = 'utf-8'
 
24
    lang                   = 'en-US'
 
25
    language               = _('English')
 
26
 
 
27
 
 
28
    remove_tags        = [dict(name=['embed','object'])]
 
29
    keep_only_tags     = [dict(name='div', attrs={'id':'contentArea'})]
 
30
 
 
31
    feeds          = [(u'NOAA articles', u'http://www.rss.noaa.gov/noaarss.xml')]
 
32
 
 
33
    def preprocess_html(self, soup):
 
34
        soup.html['xml:lang'] = self.lang
 
35
        soup.html['lang']     = self.lang
 
36
        mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
 
37
        mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=UTF-8")])
 
38
        soup.head.insert(0,mlang)
 
39
        soup.head.insert(1,mcharset)
 
40
        return self.adeify_images(soup)
 
41