View Single Post
Old 10-16-2016, 08:59 AM   #1
n3rts
Junior Member
n3rts began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Oct 2016
Device: Kindle
Subscription based recipe help!

Hi there,

I'm trying to create a recipe for an italian newspaper called "IlFoglio".
This is based on their RSS feed here:

http://www.ilfoglio.it/download/giornata/ilfoglio.rss
and attempts to login to the site (using my details)
http://www.ilfoglio.it/login.php

Is there any good soul out there able to help me on this?
Please note this is a variation of the built in recipe for this newspaper.

Thanks!
Code:
#!/usr/bin/env python2
# vim:fileencoding=utf-8
    
import string, re
from calibre import strftime
from calibre.web.feeds.recipes import BasicNewsRecipe
from calibre.ebooks.BeautifulSoup import BeautifulSoup

class Ilfoglio2(BasicNewsRecipe):

    title       = 'Ilfoglio'
    __author__  = 'n3rts'
    description = 'Daily news from the ilFoglio'
    timefmt = ' [%a, %d %b, %Y]'
    needs_subscription = True
    no_stylesheets = True

    def get_browser(self):
        br = BasicNewsRecipe.get_browser(self)
        if self.username is not None and self.password is not None:
            br.open('http://www.ilfoglio.it/login.php')
            br.select_form(name='login')
            br['********@gmail.com']   = self.username
            br['********'] = self.password
            br.submit()
        return br

    def parse_index(self):
        soup = self.index_to_soup('http://www.ilfoglio.it/home/index.htm')

Last edited by PeterT; 10-16-2016 at 03:02 PM. Reason: adding code tags to preserve indentations
n3rts is offline   Reply With Quote