|
|
#1 |
|
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Aug 2014
Device: none
|
print_version for BBC Arabic
I'm still a newbie when it comes to recipes. However, I made a simple recipe for BBC Arabic that worked well with default URLs and auto_cleanup. The only problem was some repetitive text about using Java etc in every article that had a video in it.
I tried to use the print_version feature, but it didn't work; here's what I used: def print_version(self, url): return url.replace('.shtml', '.shtml?print=1') Note: The only difference between the original article url and the print version is that the print version has ".shtml?print=1" instead of ".shtml?" at the end. Here's the RSS feed: http://www.bbc.co.uk/arabic/index.xml Here's a sample original article url: http://www.bbc.co.uk/arabic/middleea...nterview.shtml And here's the print version for the same article: http://www.bbc.co.uk/arabic/middleea....shtml?print=1 Also, I'd like to learn what code to add to delete certain repetitive text, i.e. how to replace it with nothing. Many thanks |
|
|
|
|
|
#2 |
|
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Aug 2014
Device: none
|
Update
The print_version function actually works correctly, but the issue is with the BBC page itself; it treats Calibre as a mobile device and shows the above-mentioned video instructions even in the print version, although these instructions are not shown in "desktop" Firefox.
I had to use the remove_tags feature to get rid of the annoying instructions. Here's the simple recipe for BBC Arabic Middle East. I hope it will be enhanced and added to the built-in recipes in Calibre: Code:
from calibre.web.feeds.news import BasicNewsRecipe
class BBCArabic(BasicNewsRecipe):
title = u'BBC Arabic Middle East'
oldest_article = 7
max_articles_per_feed = 100
extra_css = 'body { text-align: right; direction:rtl; } '
auto_cleanup = True
remove_tags = [
{'class':['emp-alt-handheld', 'emp-noflash', 'emp-flashlink', 'emp-alt-screen']}
]
feeds = [(u'BBC Arabic Middle East', u'http://www.bbc.co.uk/arabic/middleeast/index.xml')]
def print_version(self, url):
return url + '?print=1'
|
|
|
|
| Advert | |
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem getting print_version to be pulled | Camper65 | Recipes | 6 | 09-13-2013 12:35 AM |
| BBC and BBC (fast) to MOBI no longer work | charlessmall18 | Recipes | 3 | 09-06-2012 09:09 AM |
| Can't get print_version to do anything | MikeBlyth | Recipes | 12 | 01-17-2012 06:42 AM |
| How to use print_version to get the print page of | Starson17 | Recipes | 0 | 06-15-2011 01:05 PM |
| SacBee print_version syntax | thczv | Recipes | 6 | 04-12-2011 10:38 AM |