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 11-25-2010, 11:33 PM   #1
mufc
Connoisseur
mufc doesn't littermufc doesn't litter
 
Posts: 99
Karma: 170
Join Date: Nov 2010
Location: Airdrie Alberta
Device: Sony 650
print#

What do you do when the article does not lead to a printable page you can look at but wants to actually print the page.
http://www.calgarysun.com/news/alber.../16301276.html
http://www.calgarysun.com/news/alber...276.html#print
mufc is offline   Reply With Quote
Old 11-26-2010, 11:23 AM   #2
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by mufc View Post
What do you do when the article does not lead to a printable page you can look at but wants to actually print the page.
It probably means there isn't any "printer ready" page. I'd just use normal keep_tag remove_tag options.
Starson17 is offline   Reply With Quote
Advert
Old 11-26-2010, 11:48 AM   #3
mufc
Connoisseur
mufc doesn't littermufc doesn't litter
 
Posts: 99
Karma: 170
Join Date: Nov 2010
Location: Airdrie Alberta
Device: Sony 650
Ok I have another one

This does have a print version
http://www.mensfitness.com/fitness/b...t_training/806
http://www.mensfitness.com/fitness/b...ng/806?print=1
mufc is offline   Reply With Quote
Old 11-26-2010, 12:38 PM   #4
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Yes, that shows a print page. Many sites do. Do you have a question?
Starson17 is offline   Reply With Quote
Old 11-26-2010, 01:28 PM   #5
mufc
Connoisseur
mufc doesn't littermufc doesn't litter
 
Posts: 99
Karma: 170
Join Date: Nov 2010
Location: Airdrie Alberta
Device: Sony 650
Yes, Sorry.
What is the correct code to pull the print version ?

Oh by the way I found some of your code that relates to turning hyperlinks in articles to plain text. Thanks.
I was using a piece of code in extra css that removed all underlines from all links but left the background color. I like your way better.

Last edited by mufc; 11-26-2010 at 01:33 PM.
mufc is offline   Reply With Quote
Advert
Old 11-26-2010, 03:06 PM   #6
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by mufc View Post
Yes, Sorry.
What is the correct code to pull the print version ?
It looks like you just add "?print=1" to the url.
Code:
    def print_version(self, url):
        return url + "?print=1"
Quote:
Oh by the way I found some of your code that relates to turning hyperlinks in articles to plain text. Thanks.
I was using a piece of code in extra css that removed all underlines from all links but left the background color. I like your way better.
I'm glad it was useful.
Starson17 is offline   Reply With Quote
Old 11-26-2010, 03:26 PM   #7
mufc
Connoisseur
mufc doesn't littermufc doesn't litter
 
Posts: 99
Karma: 170
Join Date: Nov 2010
Location: Airdrie Alberta
Device: Sony 650
I had tried something similar without much success. This does not seem to work either.
http://www.mensfitness.com/rss_global/
This pages leads to main rss feed then when I link to an article it gives me print option but the code you gave me did not work unless I have done something wrong.

class AdvancedUserRecipe1289709253(BasicNewsRecipe):
title = u'test'
oldest_article = 7
max_articles_per_feed = 100
use_embedded_content = False
no_stylesheets = True

remove_javascript = True
extra_css = '.headline {font-size: x-large;} \n .fact { padding-top: 10pt }'






feeds = (u'News', u'http://www.mensfitness.com/rss_global/')



def preprocess_html(self, soup):
for alink in soup.findAll('a'):
if alink.string is not None:
tstr = alink.string
alink.replaceWith(tstr)
return soup

def print_version(self, url):
return url + "?print=1"
mufc is offline   Reply With Quote
Old 11-26-2010, 09:09 PM   #8
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
If you want your code tested or looked over, you have to post inside CODE tags (the #symbol). Otherwise we can't see the indents.
Quote:
Originally Posted by mufc View Post
I had tried something similar without much success. This does not seem to work either.
http://www.mensfitness.com/rss_global/
This pages leads to main rss feed then when I link to an article it gives me print option but the code you gave me did not work unless I have done something wrong.
Add some print statements into your recipe to see what's happening.
Starson17 is offline   Reply With Quote
Old 11-27-2010, 11:01 AM   #9
mufc
Connoisseur
mufc doesn't littermufc doesn't litter
 
Posts: 99
Karma: 170
Join Date: Nov 2010
Location: Airdrie Alberta
Device: Sony 650
oK I did my own recipe for Macleans and this works.
Code:
class AdvancedUserRecipe1289709253(BasicNewsRecipe):
    title          = u'Macleans Magazine'
    oldest_article = 7
    max_articles_per_feed = 100
    use_embedded_content  = False
    no_stylesheets = True

    remove_javascript     = True
    extra_css      = '.headline {font-size: x-large;} \n .fact { padding-top: 10pt  }'

    remove_tags_before = dict(id='')
    remove_tags = [dict(name='div', attrs={'class':['wp-caption','']}),
                   dict(name='div', attrs={'id':['headerimg','footer',]}),
                   dict(name='ul', attrs={'class':['']}),
                   dict(name='ul', attrs={'id':['']}),
				   dict(name='ol', attrs={'id':['']}),
				   dict(name='span', attrs={'class':['']}),
				   dict(name='p', attrs={'class':'postmetadata'}),
                   dict(name='img'),]

    feeds          = [(u'Canada', u'http://www2.macleans.ca/category/canada/feed/')
                          
                          ]
						  
    def preprocess_html(self, soup):
        for alink in soup.findAll('a'):
            if alink.string is not None:
               tstr = alink.string
               alink.replaceWith(tstr)
        return soup


    def print_version(self, url):
        return url + "print/"
But Men's Fitness would not
Code:
class AdvancedUserRecipe1289709253(BasicNewsRecipe):
  title = u'test'
  oldest_article = 7
  max_articles_per_feed = 100
  use_embedded_content = False
  no_stylesheets = True

  remove_javascript = True
  extra_css = '.headline {font-size: x-large;} \n .fact { padding-top: 10pt }'






  feeds = (u'News', u'http://www.mensfitness.com/rss_global/')



  def preprocess_html(self, soup):
  for alink in soup.findAll('a'):
  if alink.string is not None:
  tstr = alink.string
  alink.replaceWith(tstr)
  return soup

  def print_version(self, url):
      return url + "?print=1"
I have since redone Men's Fitness using to remove_tags etc but being OCD
I want to get the print option correct.

Code:
class AdvancedUserRecipe1289709253(BasicNewsRecipe):
    title          = u'Mens Fitness'
    oldest_article = 7
    max_articles_per_feed = 100
    use_embedded_content  = False
    no_stylesheets = True

    remove_javascript     = True
    extra_css      = '.headline {font-size: x-large;} \n .fact { padding-top: 10pt  }'


    keep_only_tags = [dict(name='div', attrs={'id':'content_items'})]
    remove_attributes = ['style', '']

    remove_tags_before = dict(id='')
    remove_tags = [dict(name='div', attrs={'class':['','']}),
                   dict(name='div', attrs={'id':['','',]}),
                   dict(name='ul', attrs={'class':['']}),
                   dict(name='ul', attrs={'id':['']}),
	dict(name='ol', attrs={'id':['']}),
	dict(name='span', attrs={'class':['']}),
	dict(name='p', attrs={'id':''}),
                   dict(name='img'),]

    feeds          = (u'News', u'http://www.mensfitness.com/rss_global/')



    def preprocess_html(self, soup):
        for alink in soup.findAll('a'):
            if alink.string is not None:
               tstr = alink.string
               alink.replaceWith(tstr)
        return soup

Last edited by mufc; 11-27-2010 at 11:11 AM.
mufc is offline   Reply With Quote
Old 11-27-2010, 02:09 PM   #10
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by mufc View Post
But Men's Fitness would not
Spoiler:
Code:
class AdvancedUserRecipe1289709253(BasicNewsRecipe):
  title = u'test'
  oldest_article = 7
  max_articles_per_feed = 100
  use_embedded_content = False
  no_stylesheets = True

  remove_javascript = True
  extra_css = '.headline {font-size: x-large;} \n .fact { padding-top: 10pt }'

  feeds = (u'News', u'http://www.mensfitness.com/rss_global/')

  def preprocess_html(self, soup):
  for alink in soup.findAll('a'):
  if alink.string is not None:
  tstr = alink.string
  alink.replaceWith(tstr)
  return soup

  def print_version(self, url):
      return url + "?print=1"
The Recipe above here won't run preprocess_html as it has incorrect indents.
Quote:
I want to get the print option correct.
You need to debug with print statements to find out why.
Starson17 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Print vs Pixel: retailers experiment with print/ebook bundles DMcCunney General Discussions 42 09-15-2010 11:29 AM
How to Print? Lady Fitzgerald Calibre 10 05-14-2010 03:58 PM
iPad The iPad can not Print ??? yvanleterrible Apple Devices 74 04-17-2010 03:13 PM
Do you print out PDFs? Nate the great Workshop 13 02-18-2008 06:36 PM
Google Print TadW Lounge 0 12-18-2003 07:35 PM


All times are GMT -4. The time now is 04:39 AM.


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