diff --git a/recipes/bloomberg-business-week.recipe b/recipes/bloomberg-business-week.recipe index 2e594caf41..290cfe4ae9 100644 --- a/recipes/bloomberg-business-week.recipe +++ b/recipes/bloomberg-business-week.recipe @@ -21,7 +21,7 @@ def get_contents(x): return '
' + x.get('value', '') + ''.join(map(get_contents, x.get('content'))) + '
' elif otype == 'media': if x['subType'] == 'photo': - return '
{}
'.format( + return '
{}
'.format( x['data']['photo']['src'], x['data']['photo']['caption']) elif x['subType'] == 'chart': if x['data'] and x['data']['chart']: @@ -58,11 +58,11 @@ class Bloomberg(BasicNewsRecipe): simultaneous_downloads = 3 extra_css = ''' - #bold {font-weight:bold;} - #auth {font-size:small; font-weight:bold;} - #time, .chart {font-size:small;} - #subhead {font-style:italic; color:#404040;} - .news-figure-caption-text, #cap, #img {font-size:small; text-align:center;} + .auth {font-size:small; font-weight:bold;} + .time, .chart {font-size:small;} + .subhead {font-style:italic; color:#404040;} + .cat {font-size:small; color:gray;} + .news-figure-caption-text, .cap, .img {font-size:small; text-align:center;} .news-figure-credit {font-size:small; text-align:center; color:#202020;} ''' diff --git a/recipes/bloomberg.recipe b/recipes/bloomberg.recipe index 19eb87da8d..e7d743d2e7 100644 --- a/recipes/bloomberg.recipe +++ b/recipes/bloomberg.recipe @@ -22,11 +22,11 @@ def get_contents(x): return '
' + x.get('value', '') + ''.join(map(get_contents, x.get('content'))) + '
' elif otype == 'media': if x['subType'] == 'photo': - return '
{}
'.format( + return '
{}
'.format( x['data']['photo']['src'], x['data']['photo']['caption']) elif x['subType'] == 'chart': if x['data'] and x['data']['chart']: - return '
'.format(x['data']['chart']['fallback']) + return '
'.format(x['data']['chart']['fallback']) elif otype == 'link': if x['data'] and x['content'] and x['content'][0] and x['content'][0]['value']: if 'href' in x['data']: @@ -53,7 +53,6 @@ class Bloomberg(BasicNewsRecipe): use_embedded_content = False remove_attributes = ['style', 'height', 'width'] ignore_duplicate_articles = {'url', 'title'} - resolve_internal_links = True # delay = 7 # seconds simultaneous_downloads = 3 diff --git a/recipes/icons/inc42.png b/recipes/icons/inc42.png new file mode 100644 index 0000000000..9edc13d383 Binary files /dev/null and b/recipes/icons/inc42.png differ diff --git a/recipes/inc42.recipe b/recipes/inc42.recipe new file mode 100644 index 0000000000..5aaa10ddb3 --- /dev/null +++ b/recipes/inc42.recipe @@ -0,0 +1,65 @@ +from calibre.ptempfile import PersistentTemporaryFile +from calibre.web.feeds.news import BasicNewsRecipe, classes + +class inc42(BasicNewsRecipe): + title = 'Inc42' + __author__ = 'unkn0wn' + description = 'Inc42 is India’s largest tech media platform working with the mission to accelerate the GDP of India’s tech & startup economy.' + no_stylesheets = True + use_embedded_content = False + encoding = 'utf-8' + language = 'en_IN' + remove_attributes = ['style', 'height', 'width'] + masthead_url = 'https://omcdn.inc42.com/users/d0ffd8ffa0d2/images/4477fc48bee71659696918-color-black-1-e1576150264134.png?width=224' + + keep_only_tags = [ + classes('entry-header entry-content'), + ] + + remove_tags = [ + dict(name='button'), + classes('also-read slick-list slides-three common-card'), + ] + + ignore_duplicate_articles = {'title'} + remove_empty_feeds = True + + articles_are_obfuscated = True + + def get_obfuscated_article(self, url): + br = self.get_browser() + try: + br.open(url) + except Exception as e: + url = e.hdrs.get('location') + soup = self.index_to_soup(url) + link = soup.find('a', href=True) + skip_sections =[ # add sections you want to skip + '/video/', '/videos/', '/media/' + ] + if any(x in link['href'] for x in skip_sections): + self.log('Aborting Article ', link['href']) + self.abort_article('skipping video links') + + self.log('Downloading ', link['href']) + html = br.open(link['href']).read() + pt = PersistentTemporaryFile('.html') + pt.write(html) + pt.close() + return pt.name + + feeds = [] + + sections = [ + 'features', 'buzz', 'startups', 'resources' + ] + + for sec in sections: + a = 'https://news.google.com/rss/search?q=when:27h+allinurl:inc42.com{}&hl=en-IN&gl=IN&ceid=IN:en' + feeds.append((sec.capitalize(), a.format('%2F' + sec + '%2F'))) + feeds.append(('Others', a.format(''))) + + def preprocess_html(self, soup): + for img in soup.findAll('img', attrs={'data-src':True}): + img['src'] = img['data-src'] + return soup