From dcda88a054e076ef609edf21688216d66eefdc3a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 2 Jan 2010 09:13:45 -0700 Subject: [PATCH] New recipe for Entrepreneur Magazine by kwetal --- resources/images/news/entrepeneur.png | Bin 0 -> 551 bytes resources/recipes/entrepeneur.recipe | 76 ++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 resources/images/news/entrepeneur.png create mode 100644 resources/recipes/entrepeneur.recipe diff --git a/resources/images/news/entrepeneur.png b/resources/images/news/entrepeneur.png new file mode 100644 index 0000000000000000000000000000000000000000..9f732a0c8175314efffbaffaa0df012e6e41dc20 GIT binary patch literal 551 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmUzPnffIy#(^vlDyqr z82*Fcg1yTp14TFsJR*yMvQ&rUPlPc?>bf)*fbHV3hWBaSX9IJ$K?p zufqWnt@~%QxULa8v&e7z`Ul)9TZ6Zk6`j3x^Wt=YBS)9E+Bw7@aEh55W3|0Ipny}U zX{Y9X=bpp9w?g=3c6`56{Ovp|EANvjp=_YWbyppv0 zA8_;7sncse?7J4DBPRO1dXmBWlANDcjHe|{JAMCajX}cPWjpru%eP6a3g}nZc4Mm3 zEX}Jw*wmSGrfGa%ckRkgqXUKwXN7D9tCZ#(H7vDbuDJQ^UBxfSS)RdWKexqwn5EKd z{Nc1A`cUHBS@`x%nxXX_W{Kh9QQ=APpvF5DoSp zU6uhgNP=t#&QB{TPb^Aha7@WhN>%X8O-xS>N=;0uEIgTN160J|>FVdQ&MBb@0OC~B A@Bjb+ literal 0 HcmV?d00001 diff --git a/resources/recipes/entrepeneur.recipe b/resources/recipes/entrepeneur.recipe new file mode 100644 index 0000000000..b6bfe1f7c7 --- /dev/null +++ b/resources/recipes/entrepeneur.recipe @@ -0,0 +1,76 @@ +from calibre.web.feeds.news import BasicNewsRecipe +import re + +class EntrepeneurRecipe(BasicNewsRecipe): + __license__ = 'GPL v3' + __author__ = 'kwetal' + language = 'en' + version = 1 + + title = u'Entrepeneur' + publisher = u'Entrepreneur Media, Inc' + category = u'Business' + description = u'Online magazine on business, small business, management and economy' + + oldest_article = 21 + max_articles_per_feed = 100 + use_embedded_content = False + encoding = 'utf-8' + + remove_empty_feeds = True + no_stylesheets = True + remove_javascript = True + + keep_only_tags = [] + keep_only_tags.append(dict(name = 'div', attrs = {'id': 'printbody'})) + + remove_tags = [] + remove_tags.append(dict(name = 'base')) + remove_tags.append(dict(name = 'a', attrs = {'id': 'ctl00_privacyPolicyLink'})) + + remove_attributes = ['style'] + + # feeds from http://www.entrepreneur.com/feeds/index.html + feeds = [] + feeds.append((u'The Latest Headlines', u'http://feeds.feedburner.com/entrepreneur/latest')) + feeds.append((u'Starting a Business', u'http://feeds.feedburner.com/entrepreneur/startingabusiness.rss')) + feeds.append((u'Grow Your Business', u'http://feeds.feedburner.com/entrepreneur/growingyourbusiness.rss')) + feeds.append((u'Sales and Marketing', u'http://feeds.feedburner.com/entrepreneur/salesandmarketing')) + feeds.append((u'Online Business', u'http://feeds.feedburner.com/entrepreneur/ebiz')) + feeds.append((u'Franchises', u'http://feeds.feedburner.com/entrepreneur/franchises')) + #feeds.append((u'', u'')) + + extra_css = ''' + body{font-family:verdana,arial,helvetica,geneva,sans-serif;} + img {float: left; margin-right: 0.5em;} + a, a[href] {text-decoration: none; color: blue;} + div#ctl00_bodyContentPlaceHolder_articleHeader_divHeaderText {font-weight: bold; + font-size: medium;} + h1 {font-size: xx-large; font-weight: bold;} + div.byline {font-size: small; color: #696969; font-weight: normal;} + a.h2 {font-size: medium; font-weight: bold; color: #666666; text-decoration: none; + margin-bottom: 0em;} + ''' + + def get_article_url(self, article): + return article.feedburner_origlink + + def print_version(self, url): + id = url.rpartition('/')[2].replace('article', '') + + return 'http://www.entrepreneur.com/article/printthis/' + id + + def preprocess_html(self, soup): + div = soup.find('div', attrs = {'id': 'printbody'}) + if div: + a = div.find(lambda tag: tag.name == 'a' and len(tag.attrs) == 1) + if a: + txt = a.findPreviousSibling(text = re.compile('URL:.*')) + if txt: + txt.extract() + for br in a.findNextSiblings('br'): + br.extract() + a.extract() + + return soup +