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 12-21-2013, 10:15 AM   #1
scissors
Addict
scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.
 
Posts: 241
Karma: 1001369
Join Date: Sep 2010
Device: prs300, kindle keyboard 3g
can't reduce font size of headline using extra css

Hi All,

I'm having trouble, I can't reduce the font size of the h1 headlines in a recipe i'm working on. I've tried various labels to reference ie : .article-page h1 etc

The articles pages are here
can anyone suggest what i'm doing wrong?

recipe

Spoiler:
Code:
from calibre.web.feeds.news import BasicNewsRecipe
from calibre import browser
import re
import mechanize
from calibre.utils.magick import Image

class AdvancedUserRecipe1306097511(BasicNewsRecipe):
    title          = u'Birmingham Evening Mail'
    description = 'News for Birmingham UK'
    #timefmt = ''
    __author__ = 'Dave Asbury'
    # v1 21/12/13
    masthead_url        = 'http://images.icnetwork.co.uk/upl/icbirmingham/apr2004/6/5/0007417F-982A-107F-969980BFB6FA0000.jpg'
    oldest_article = 1
    max_articles_per_feed = 1
    #linearize_tables = True
    remove_empty_feeds = True
    remove_javascript     = True
    no_stylesheets = True
    #auto_cleanup = True
    language = 'en_GB'
    compress_news_images = True
    compress_news_images_max_size = 30
    ignore_duplicate_articles = {'title', 'url'}

    remove_tags = [
                                dict(attrs={'class' : 'gallery-data'}),
		dict(attrs={'class' : 'ir btn-fullscreen'}),
                                dict(attrs={'class' : 'tools clearfix'}),

		]
    keep_only_tags = [
                  	#dict(attrs={'class' : 'styleGroup article-header'}),
                 	#dict(attrs={'class' : 'body '}),
                 	dict(attrs={'class' : 'tmCol article'}),]

    feeds          = [
        (u'Local News', u'http://www.birminghammail.co.uk/news/local-news/rss.xml'),
        (u'UK News', u'http://www.birminghammail.co.uk/news/uk-news/rss.xml'),
        (u'Sport', u'http://www.birminghammail.co.uk/sport/rss.xml'),
        (u'Whats On', u'http://www.birminghammail.co.uk/whats-on/rss.xml'),
        (u'Lifestyle',u'http://www.birminghammail.co.uk/lifestyle/rss.xml'),
        ]

    def get_cover_url(self):
        print '============Cover ================='
        print
        soup = self.index_to_soup('http://www.birminghammail.co.uk')
        cov = soup.find(attrs={'src' : re.compile('http://images.icnetwork.co.uk/upl/birmpost/')})
        cov=str(cov)
        print '^^^^^^^', cov
        cov2 =  re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', cov)

        cov=str(cov2)
        cov=cov[2:len(cov)-2]

        print '&&&&&&&&',cov,'***'
        cover_url=cov
        br = browser()
        br.set_handle_redirect(False)
        try:
            br.open_novisit(cov)
            cover_url = cov
        except:
            cover_url ='http://s.birminghammail.co.uk/skins/birminghammail/gfx/follow-media.jpg'

        return cover_url
    
        extra_css = '''
                    h1 {font-weight:bold;font-size: 125%;}
                    h2{font-weight:normal;font-size:75%;}
                    #p{font-size:14px;}
                    #body{font-size:14px;}
                    #.photo-caption {display: block;margin-left: auto;margin-right: auto;width:100%;font-size:40%;}
                    #.publish-info {font-size:50%;}
                    #.clearfix {display: block;margin-left: auto;margin-right: auto;width:100%;}
         '''


All help appreciate

Dave
scissors is offline   Reply With Quote
Old 12-21-2013, 12:00 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Try telling the recipe to remove the style attribute as well, via remove_attributes = ['style']
kovidgoyal is offline   Reply With Quote
Advert
Old 12-21-2013, 12:15 PM   #3
scissors
Addict
scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.
 
Posts: 241
Karma: 1001369
Join Date: Sep 2010
Device: prs300, kindle keyboard 3g
Quote:
Originally Posted by kovidgoyal View Post
Try telling the recipe to remove the style attribute as well, via remove_attributes = ['style']
Hi Kovid

Made no difference...
scissors is offline   Reply With Quote
Old 12-21-2013, 12:18 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Your extra_css is not properly indented, it need to be indented one level less
kovidgoyal is offline   Reply With Quote
Old 12-21-2013, 12:50 PM   #5
scissors
Addict
scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.
 
Posts: 241
Karma: 1001369
Join Date: Sep 2010
Device: prs300, kindle keyboard 3g
Quote:
Originally Posted by kovidgoyal View Post
Your extra_css is not properly indented, it need to be indented one level less
D'oh!

Thanks Kovid.

Here's the recipe for anyone from the midlands uk who may fancy it
Spoiler:
Code:
from calibre.web.feeds.news import BasicNewsRecipe
from calibre import browser
import re
import mechanize
from calibre.utils.magick import Image

class AdvancedUserRecipe1306097511(BasicNewsRecipe):
    title          = u'Birmingham Evening Mail'
    description = 'News for Birmingham UK'
    #timefmt = ''
    __author__ = 'Dave Asbury'
    # v1 21/12/13
    masthead_url        = 'http://images.icnetwork.co.uk/upl/icbirmingham/apr2004/6/5/0007417F-982A-107F-969980BFB6FA0000.jpg'
    oldest_article = 1
    max_articles_per_feed = 10
    #linearize_tables = True
    remove_empty_feeds = True
    remove_javascript     = True
    no_stylesheets = True
    remove_attributes = ['style']
    #auto_cleanup = True
    language = 'en_GB'
    compress_news_images = True
    compress_news_images_max_size = 30
    ignore_duplicate_articles = {'title', 'url'}

    remove_tags = [
                                dict(attrs={'class' : 'gallery-data'}),
		dict(attrs={'class' : 'ir btn-fullscreen'}),
                                dict(attrs={'class' : 'tools clearfix'}),

		]
    keep_only_tags = [
                  	#dict(attrs={'class' : 'styleGroup article-header'}),
                 	#dict(attrs={'class' : 'body '}),
                 	dict(attrs={'class' : 'tmCol article'}),]

    feeds          = [
        (u'Local News', u'http://www.birminghammail.co.uk/news/local-news/rss.xml'),
        (u'UK News', u'http://www.birminghammail.co.uk/news/uk-news/rss.xml'),
        (u'Sport', u'http://www.birminghammail.co.uk/sport/rss.xml'),
        (u'Whats On', u'http://www.birminghammail.co.uk/whats-on/rss.xml'),
        (u'Lifestyle',u'http://www.birminghammail.co.uk/lifestyle/rss.xml'),
        ]
    extra_css = '''
        	     h1{font-weight:bold;font-size: 175%;}
                     h2{font-weight:normal;font-size:75%;}
                    #p{font-size:14px;}
                    #body{font-size:14px;}
                    #.photo-caption {display: block;margin-left: auto;margin-right: auto;width:100%;font-size:40%;}
                    #.publish-info {font-size:50%;}
                     img {display: block;margin-left: auto;margin-right: auto;width:100%;}
                      '''
    def get_cover_url(self):
        print '============Cover ================='
        print
        soup = self.index_to_soup('http://www.birminghammail.co.uk')
        cov = soup.find(attrs={'src' : re.compile('http://images.icnetwork.co.uk/upl/birmpost/')})
        cov=str(cov)
        print '^^^^^^^', cov
        cov2 =  re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', cov)

        cov=str(cov2)
        cov=cov[2:len(cov)-2]

        print '&&&&&&&&',cov,'***'
        cover_url=cov
        br = browser()
        br.set_handle_redirect(False)
        try:
            br.open_novisit(cov)
            cover_url = cov
        except:
            cover_url ='http://s.birminghammail.co.uk/skins/birminghammail/gfx/follow-media.jpg'

        return cover_url
scissors is offline   Reply With Quote
Advert
Old 12-23-2013, 03:45 AM   #6
scissors
Addict
scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.scissors ought to be getting tired of karma fortunes by now.
 
Posts: 241
Karma: 1001369
Join Date: Sep 2010
Device: prs300, kindle keyboard 3g
Quote:
Originally Posted by scissors View Post
D'oh!

Thanks Kovid.

Here's the recipe for anyone from the midlands uk who may fancy it
Spoiler:
Code:
from calibre.web.feeds.news import BasicNewsRecipe
from calibre import browser
import re
import mechanize
from calibre.utils.magick import Image

class AdvancedUserRecipe1306097511(BasicNewsRecipe):
    title          = u'Birmingham Evening Mail'
    description = 'News for Birmingham UK'
    #timefmt = ''
    __author__ = 'Dave Asbury'
    # v1 21/12/13
    masthead_url        = 'http://images.icnetwork.co.uk/upl/icbirmingham/apr2004/6/5/0007417F-982A-107F-969980BFB6FA0000.jpg'
    oldest_article = 1
    max_articles_per_feed = 10
    #linearize_tables = True
    remove_empty_feeds = True
    remove_javascript     = True
    no_stylesheets = True
    remove_attributes = ['style']
    #auto_cleanup = True
    language = 'en_GB'
    compress_news_images = True
    compress_news_images_max_size = 30
    ignore_duplicate_articles = {'title', 'url'}

    remove_tags = [
                                dict(attrs={'class' : 'gallery-data'}),
		dict(attrs={'class' : 'ir btn-fullscreen'}),
                                dict(attrs={'class' : 'tools clearfix'}),

		]
    keep_only_tags = [
                  	#dict(attrs={'class' : 'styleGroup article-header'}),
                 	#dict(attrs={'class' : 'body '}),
                 	dict(attrs={'class' : 'tmCol article'}),]

    feeds          = [
        (u'Local News', u'http://www.birminghammail.co.uk/news/local-news/rss.xml'),
        (u'UK News', u'http://www.birminghammail.co.uk/news/uk-news/rss.xml'),
        (u'Sport', u'http://www.birminghammail.co.uk/sport/rss.xml'),
        (u'Whats On', u'http://www.birminghammail.co.uk/whats-on/rss.xml'),
        (u'Lifestyle',u'http://www.birminghammail.co.uk/lifestyle/rss.xml'),
        ]
    extra_css = '''
        	     h1{font-weight:bold;font-size: 175%;}
                     h2{font-weight:normal;font-size:75%;}
                    #p{font-size:14px;}
                    #body{font-size:14px;}
                    #.photo-caption {display: block;margin-left: auto;margin-right: auto;width:100%;font-size:40%;}
                    #.publish-info {font-size:50%;}
                     img {display: block;margin-left: auto;margin-right: auto;width:100%;}
                      '''
    def get_cover_url(self):
        print '============Cover ================='
        print
        soup = self.index_to_soup('http://www.birminghammail.co.uk')
        cov = soup.find(attrs={'src' : re.compile('http://images.icnetwork.co.uk/upl/birmpost/')})
        cov=str(cov)
        print '^^^^^^^', cov
        cov2 =  re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', cov)

        cov=str(cov2)
        cov=cov[2:len(cov)-2]

        print '&&&&&&&&',cov,'***'
        cover_url=cov
        br = browser()
        br.set_handle_redirect(False)
        try:
            br.open_novisit(cov)
            cover_url = cov
        except:
            cover_url ='http://s.birminghammail.co.uk/skins/birminghammail/gfx/follow-media.jpg'

        return cover_url
Corrected cover fetch code

Spoiler:
Code:
from calibre.web.feeds.news import BasicNewsRecipe
from calibre import browser
import re
import mechanize
from calibre.utils.magick import Image

class AdvancedUserRecipe1306097511(BasicNewsRecipe):
    title          = u'Birmingham Evening Mail'
    description = 'News for Birmingham UK'
    #timefmt = ''
    __author__ = 'Dave Asbury'
    # v1 21/12/13
    masthead_url        = 'http://images.icnetwork.co.uk/upl/icbirmingham/apr2004/6/5/0007417F-982A-107F-969980BFB6FA0000.jpg'
    oldest_article = 1
    max_articles_per_feed = 10
    #linearize_tables = True
    remove_empty_feeds = True
    remove_javascript     = True
    no_stylesheets = True
    remove_attributes = ['style']
    #auto_cleanup = True
    language = 'en_GB'
    compress_news_images = True
    compress_news_images_max_size = 30
    ignore_duplicate_articles = {'title', 'url'}

    remove_tags = [
                                dict(attrs={'class' : 'gallery-data'}),
		dict(attrs={'class' : 'ir btn-fullscreen'}),
                                dict(attrs={'class' : 'tools clearfix'}),

		]
    keep_only_tags = [
                  	#dict(attrs={'class' : 'styleGroup article-header'}),
                 	#dict(attrs={'class' : 'body '}),
                 	dict(attrs={'class' : 'tmCol article'}),]

    feeds          = [
        (u'Local News', u'http://www.birminghammail.co.uk/news/local-news/rss.xml'),
        (u'UK News', u'http://www.birminghammail.co.uk/news/uk-news/rss.xml'),
        (u'Sport', u'http://www.birminghammail.co.uk/sport/rss.xml'),
        (u'Whats On', u'http://www.birminghammail.co.uk/whats-on/rss.xml'),
        (u'Lifestyle',u'http://www.birminghammail.co.uk/lifestyle/rss.xml'),
        ]
    extra_css = '''
        	     h1{font-weight:bold;font-size: 175%;}
                     h2{font-weight:normal;font-size:75%;}
                     figure {font-size:50%;}
                    #body{font-size:14px;}
                    #.photo-caption {display: block;margin-left: auto;margin-right: auto;width:100%;font-size:40%;}
                    #.publish-info {font-size:50%;}
                     img {display: block;margin-left: auto;margin-right: auto;width:100%;font-size:50%;}
                      '''
    def get_cover_url(self):
        print '============Cover ================='
        print
        soup = self.index_to_soup('http://www.birminghammail.co.uk')
        cov = soup.find(attrs={'src' : re.compile('http://images.icnetwork.co.uk/upl/birm')})
        cov=str(cov)
        print '^^^^^^^', cov
        cov2 =  re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', cov)

        cov=str(cov2)
        cov=cov[2:len(cov)-2]

        print '&&&&&&&&',cov,'***'
        cover_url=cov
        br = browser()
        br.set_handle_redirect(False)
        try:
            br.open_novisit(cov)
            cover_url = cov
        except:
            cover_url ='http://s.birminghammail.co.uk/skins/birminghammail/gfx/follow-media.jpg'

        return cover_url
scissors 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
Formatting sgc-toc.css font-size phossler Sigil 13 09-07-2013 12:37 PM
add 2 different font paths in Extra CSS raykoko Calibre 2 08-17-2013 04:47 AM
How to change the font-size in the body tag in css? naisren Conversion 2 10-01-2012 05:52 PM
Calibre has no choice on font size unit in css? naisren ePub 6 09-30-2012 09:41 AM
css pseudo elements and adjacent combinators in extra css? ldolse Calibre 2 12-21-2010 05:09 PM


All times are GMT -4. The time now is 03:34 AM.


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