Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 11-18-2016, 11:20 PM   #1
macpablus
Enthusiast
macpablus once ate a cherry pie in a record 7 seconds.macpablus once ate a cherry pie in a record 7 seconds.macpablus once ate a cherry pie in a record 7 seconds.macpablus once ate a cherry pie in a record 7 seconds.macpablus once ate a cherry pie in a record 7 seconds.macpablus once ate a cherry pie in a record 7 seconds.macpablus once ate a cherry pie in a record 7 seconds.macpablus once ate a cherry pie in a record 7 seconds.macpablus once ate a cherry pie in a record 7 seconds.macpablus once ate a cherry pie in a record 7 seconds.macpablus once ate a cherry pie in a record 7 seconds.
 
Posts: 25
Karma: 1896
Join Date: Aug 2011
Device: Kindle 3
Pagina/12 Recipe Stopped working

I'm getting this error

"Skipping article El tiempo es veloz (Mon, 14 Nov, 2016 04:00) from feed Rosario/12 as it is too old."

It seems that the site changed it format or something...

Quote:
Code:
#!/usr/bin/env  python2

__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''
pagina12.com.ar
'''
import re

from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ebooks.BeautifulSoup import Tag, NavigableString


class Pagina12(BasicNewsRecipe):

    title = 'Pagina/12 - Edicion Impresa'
    __author__ = 'Pablo Marfil'
    description = 'Diario argentino'
    INDEX = 'http://www.pagina12.com.ar/diario/secciones/index.html'
    language = 'es'
    encoding = 'cp1252'
    remove_tags_before = dict(id='fecha')
    remove_tags_after = dict(id='fin')
    remove_tags = [dict(id=['fecha', 'fin', 'pageControls',
                            'logo', 'logo_suple', 'fecha_suple', 'volver'])]
    masthead_url = 'http://www.pagina12.com.ar/commons/imgs/logo-home.gif'
    no_stylesheets = True

    preprocess_regexps = [(re.compile(r'<!DOCTYPE[^>]+>', re.I), lambda m:'')]

    def get_cover_url(self):
        soup = self.index_to_soup(
            'http://www.pagina12.com.ar/diario/principal/diario/index.html')
        for image in soup.findAll('img', alt=True):
            if image['alt'].startswith('Tapa de la fecha'):
                return image['src']
                print image
        return None

    def parse_index(self):
        articles = []
        numero = 1
        raw = self.index_to_soup(
            'http://www.pagina12.com.ar/diario/secciones/index.html', raw=True)
        raw = re.sub(r'(?i)<!DOCTYPE[^>]+>', '', raw)
        soup = self.index_to_soup(raw)

        feeds = []

        seen_titles = set([])
        for section in soup.findAll('div', 'seccionx'):
            numero += 1
            print (numero)
            section_title = self.tag_to_string(section.find(
                'div', 'desplegable_titulo on_principal right'))
            self.log('Found section:', section_title)
            articles = []
            for post in section.findAll('h2'):
                h = post.find('a', href=True)
                title = self.tag_to_string(h)
                if title in seen_titles:
                    continue
                seen_titles.add(title)
                a = post.find('a', href=True)
                url = a['href']
                if url.startswith('/'):
                    url = 'http://pagina12.com.ar/imprimir' + url
                p = post.find('div', attrs={'h2'})
                desc = None
                self.log('\tFound article:', title, 'at', url)
                if p is not None:
                    desc = self.tag_to_string(p)
                    self.log('\t\t', desc)
                articles.append({'title': title, 'url': url, 'description': desc,
                                 'date': ''})
            if articles:
                feeds.append((section_title, articles))
        return feeds

    def postprocess_html(self, soup, first):
        for table in soup.findAll('table', align='right'):
            img = table.find('img')
            if img is not None:
                img.extract()
                caption = self.tag_to_string(table).strip()
                div = Tag(soup, 'div')
                div['style'] = 'text-align:center'
                div.insert(0, img)
                div.insert(1, Tag(soup, 'br'))
                if caption:
                    div.insert(2, NavigableString(caption))
                table.replaceWith(div)

        return soup

Last edited by PeterT; 11-18-2016 at 11:40 PM.
macpablus is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Boston Globe recipe has stopped working NSILMike Recipes 3 10-16-2012 05:22 PM
Built in recipe for Ottawa Citizen stopped working sylviebi Recipes 3 08-14-2012 06:48 PM
Men's Health Recipe has stopped working Syzygus Recipes 0 08-15-2011 06:22 AM
Guardian Recipe has stopped working jbambridge Calibre 2 04-11-2010 02:14 PM
Stopped working? pshrynk Calibre 8 02-14-2009 05:43 PM


All times are GMT -4. The time now is 09:24 PM.


MobileRead.com is a privately owned, operated and funded community.