View Single Post
Old 11-04-2010, 04:54 AM   #1
marbs began at the beginning.
Posts: 122
Karma: 10
Join Date: Jul 2010
Device: nook
new Ynet recipie to be builtin

new recipe. i hope people enjoy it.

from import BasicNewsRecipe
from calibre.ebooks.BeautifulSoup import BeautifulSoup, re
import mechanize 

class AdvancedUserRecipe1283848012(BasicNewsRecipe):
    description   = 'This is a recipe of The recipe opens the article page and clicks on an advertisement to not hurt the sites advertising income.'
    cover_url      = ''
    title          = u'Ynet'
    __author__ = 'marbs'
    language              = _('Hebrew')
    extra_css='img {max-width:100%;direction: rtl;} #article{direction: rtl;} div{direction: rtl;} title{direction: rtl; } article_description{direction: rtl; } a.article{direction: rtl; } calibre_feed_description{direction: rtl; } body{direction: ltr;}'
    remove_attributes = ['width']
    simultaneous_downloads = 5
    keep_only_tags =dict(name='div', attrs={'id':'articleContainer'}) 
    remove_javascript     = True
    timefmt        = '[%a, %d %b, %Y]'
    oldest_article = 1
    remove_tags = [dict(name='p', attrs={'text':[' ']})]
    max_articles_per_feed = 100
    preprocess_regexps = [
        (re.compile(r'<p>&nbsp;</p>', re.DOTALL|re.IGNORECASE), lambda match: '')

    def preprocess_html(self, soup):
        soup.html['dir'] = 'rtl'
        soup.body['dir'] = 'rtl'
        return soup

    feeds          = [(u'חדשות', u''),                            
                           (u'כלכלה', u''), 
                           (u'צרכנות', u''), 
                           (u'ספורט', u''), 
                           (u'תרבות', u''), 
                           (u'מעורבות וחברה', u''), 
                           (u'בריאות', u''), 
                           (u'ירוק', u''), 
                           (u'מחשבים', u''), 
                           (u'רכב', u''), 
                           (u'תיירות', u''), 
                           (u'הורים', u''), 
                           (u'אוכל', u''), 
                           (u'יהדות', u''), 
                           (u'מדע וטבע', u''), 
                           (u'יחסים', u''), 
                           (u'דעות', u'')]
    def print_version(self, url):
#remove from here
        br = BasicNewsRecipe.get_browser()
        response = br.follow_link(mechanize.Link(base_url = '', url =url, text = '', tag = 'a', attrs = [{'id':'buzzerATop'}])) 
#to here to stop supporting ynet...        
        print 'ORG URL IS: ', url
        split1 = url.split("-")
        print 'THE SPLIT IS: ', split1 
        weblinks = url
        print_url = ',2506,L-' + split1[1]                 
        print 'THIS URL WILL PRINT: ', print_url # this is a test string to see what the url is it will return
        return print_url
marbs is offline   Reply With Quote