Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 09-10-2021, 01:03 PM   #1
oneillpt
Connoisseur
oneillpt began at the beginning.
 
Posts: 63
Karma: 46
Join Date: Feb 2011
Device: Kindle 3 (cracked screen!); PW1; Oasis
Updated Аргументы и Факты (Russian) recipe

Updated recipe

Code:
#!/usr/bin/env python
# vim:fileencoding=utf-8
from __future__ import with_statement, unicode_literals
from calibre.web.feeds.news import BasicNewsRecipe
from calibre.web.fetch.simple import (
AbortArticle, RecursiveFetcher, option_parser as web2disk_option_parser
)
import string as st
import calibre.web.feeds.news
import os, sys
dir(BeautifulSoup)

class AdvancedUserRecipe1592177429(BasicNewsRecipe):
    title = 'Аргументы и Факты'
    encoding = 'utf8'
    language = 'ru'
    oldest_article = 7
    max_articles_per_feed = 25
    verbose = 3

    feeds = [
        ('AIF', 'https://www.aif.ru/rss/all.php'),
    ]
    INDEX = 'https://www.aif.ru/rss/all.php'

    def parse_index(self):
        feeds = []
        section_title = u'aif'
        articles = []
        soup = self.index_to_soup(self.INDEX)
        ii = 0
        for item in soup.findAll('item'):
            if ii < self.max_articles_per_feed:
               try:
                    ii = ii + 1
                    A = str(item)
                    i = A.find(u'link')
                    j = A.find(u'description')
                    ZZ = item.find('description')
                    ZZ1 = str(ZZ)  # bs4.element.Tag to str
                    ZZ2 = ZZ1[24:-19]
                    AU = A[i:j]
                    try:
                        articles.append({'url':AU[6:-2], 'title':ZZ2})
                    except Exception as inst:
                except Exception as inst:
                    self.log("Exception handled!")
        if articles:
            feeds.append((section_title, articles))
        return feeds
oneillpt is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[KUAL] Turn OFF button \ Выключение устройства (кнопка) Arhim Kindle Developer's Corner 24 08-05-2013 08:14 PM


All times are GMT -4. The time now is 04:42 PM.


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