05-15-2011, 10:53 AM | #1 |
Enthusiast
Posts: 37
Karma: 10
Join Date: Apr 2011
Device: none
|
Recipe for cosmopolitan US
J'd like to create recipe for cosmopolitan US
J want to use print version and in order to do that J need to change url of articles. for instance: from: http://www.cosmopolitan.com/sex-love/dating-advice/tips-for-long-distance-relationships?src=rss to: http://www.cosmopolitan.com/print-this/tips-for-long-distance-relationships?src=rss and J don't know how to do this? any help? this is source code: Code:
class AdvancedUserRecipe1305470859(BasicNewsRecipe): title = u'Cosmopolitan' oldest_article = 14 max_articles_per_feed = 100 feeds = [(u'Sex & Love', u'http://www.cosmopolitan.com/sex-love/rss/'), (u'Hair & Beauty', u'http://www.cosmopolitan.com/hairstyles-beauty/rss/'), (u'Celebs & Style', u'http://www.cosmopolitan.com/celebrity/rss/'), (u'Secrets & Advice', u'http://www.cosmopolitan.com/advice/rss/')] Last edited by xXxXxXxXxXx; 05-15-2011 at 11:24 AM. |
05-16-2011, 08:37 AM | #2 |
Zealot
Posts: 119
Karma: 100
Join Date: Jan 2011
Location: Germany / NRW /Köln
Device: prs-650 / prs-350 /kindle 3
|
try this
Code:
class AdvancedUserRecipe1305470859(BasicNewsRecipe): title = u'Cosmopolitan Magazin' oldest_article = 14 max_articles_per_feed = 20 no_stylesheets = True use_embedded_content = False remove_javascript = True cover_url = 'http://www.cosmopolitan.com/cm/shared/site_images/print_this/cosmopolitan_logo.gif' extra_css = ''' h2{font-family:Arial,Helvetica,sans-serif; font-size: x-small;} h1{ font-family:Arial,Helvetica,sans-serif; font-size:x-large; font-weight:bold;} ''' remove_tags = [dict(name='div', attrs={'class':'printTools'})] def print_version(self,url): segments = url.split('/') printURL = '/'.join(segments[0:3]) + '/print-this/' + '/'.join(segments[4:]) return printURL 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 feeds = [(u'Sex&Love', u'http://www.cosmopolitan.com/sex-love/rss/'), (u'Hair&Beauty', u'http://www.cosmopolitan.com/hairstyles-beauty/rss/'), (u'Celebs & Style', u'http://www.cosmopolitan.com/celebrity/rss/'), (u'Secrets & Advice', u'http://www.cosmopolitan.com/advice/rss/'), (u'Sexy Beauty Secrets Blog', u'http://www.cosmopolitan.com/hairstyles-beauty/beauty-blog/rss/'), (u'Joe Hottie`s Dating Blog', u'http://www.cosmopolitan.com/sex-love/joe-hottie/joe-hottie-rss/'), (u'Bedroom Blog', u'http://www.cosmopolitan.com/sex-love/bedroom-blog/rss/')] |
Advert | |
|
05-16-2011, 08:56 AM | #3 |
Enthusiast
Posts: 37
Karma: 10
Join Date: Apr 2011
Device: none
|
Thank you,
J want to create my own recipe, but J always have problems with changing url to print version, Could you explain this: (write comment in each line what you do )? def print_version(self,url): segments = url.split('/') printURL = '/'.join(segments[0:3]) + '/print-this/' + '/'.join(segments[4:]) return printURL 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 |
05-16-2011, 09:08 AM | #4 | |
Zealot
Posts: 119
Karma: 100
Join Date: Jan 2011
Location: Germany / NRW /Köln
Device: prs-650 / prs-350 /kindle 3
|
Quote:
Code:
https://www.mobileread.com/forums/showpost.php?p=1231995&postcount=9 Code:
https://www.mobileread.com/forums/showpost.php?p=1488098&postcount=4 greetings |
|
05-16-2011, 09:51 AM | #5 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
https://www.mobileread.com/forums/sho...9&postcount=12 |
|
Advert | |
|
05-16-2011, 10:23 AM | #6 |
Zealot
Posts: 119
Karma: 100
Join Date: Jan 2011
Location: Germany / NRW /Köln
Device: prs-650 / prs-350 /kindle 3
|
good idea
|
Tags |
recipe |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Recipe works when mocked up as Python file, fails when converted to Recipe | ode | Recipes | 7 | 09-04-2011 04:57 AM |
Recipe for ng.pl | markoz | Recipes | 4 | 04-13-2011 05:03 PM |
recipe please | Torx | Recipes | 0 | 01-22-2011 12:18 PM |
Recipe help | kool | Recipes | 3 | 10-22-2010 03:34 PM |
New recipe | kiklop74 | Recipes | 0 | 10-01-2010 02:42 PM |