View Single Post
Old 09-03-2010, 05:56 AM   #2608
c.espinosas
Junior Member
c.espinosas began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Sep 2010
Device: entourage edge
Quote:
Originally Posted by bmsleight View Post
Hi c.espinosas,

Try this for a recipe for Milenio Diario (mexican newspaper, http://impreso.milenio.com/Nacional/)

Although I do not speak Spanish, so there maybe some errors.

Spoiler:
Code:
#!/usr/bin/env  python
__license__   = 'GPL v3'
__copyright__ = '2010, Brendan Sleight <bms.calibre at barwap.com>'
'''
impreso.milenio.com
'''
from calibre import strftime
from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ebooks.BeautifulSoup import BeautifulSoup

import datetime
import string

class Milenio(BasicNewsRecipe):
    title                 = u'Milenio-diario'
    __author__            = 'Bmsleight'
    description           = 'Milenio-diario'
    oldest_article        = 10
    max_articles_per_feed = 100
    no_stylesheets        = False
    index                 = 'http://impreso.milenio.com'

    keep_only_tags      = [
                           dict(name='div', attrs={'class':'content'})
                          ]

    def parse_index(self):
        # "%m/%d/%Y"
        # http://impreso.milenio.com/Nacional/2010/09/01/
        totalfeeds = []
        soup   = self.index_to_soup(self.index + "/Nacional/" + datetime.date.today().strftime("%Y/%m/%d"))
        maincontent = soup.find('div',attrs={'class':'content'})
        mfeed = []
        if maincontent:
            for itt in maincontent.findAll('a',href=True):
                if "/node/" in str(itt['href']):
                    url   = self.index + itt['href']
                    title = self.tag_to_string(itt)
                    description = ''
                    date  = strftime(self.timefmt)
                    mfeed.append({
                                  'title'      :title
                                 ,'date'       :date
                                 ,'url'        :url
                                 ,'description':description
                                })
        totalfeeds.append(('Articles', mfeed))
        return totalfeeds


Anyone help me on https://www.mobileread.com/forums/sho...postcount=2568 (instructable) ?

Regards,
Brendan
Many thanks Brendan!
I already tried it, and works very well.
Best,
Carlos
c.espinosas is offline