| 1 |
import re |
| 2 |
|
| 3 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 4 |
|
| 5 |
|
| 6 |
class BigOven(BasicNewsRecipe): |
| 7 |
title = 'BigOven' |
| 8 |
__author__ = 'Starson17' |
| 9 |
description = 'Recipes for the Foodie in us all. Registration is free. A fake username and password just gives smaller photos.' |
| 10 |
language = 'en' |
| 11 |
category = 'news, food, recipes, gourmet' |
| 12 |
publisher = 'Starson17' |
| 13 |
use_embedded_content = False |
| 14 |
no_stylesheets = True |
| 15 |
oldest_article = 24 |
| 16 |
remove_javascript = True |
| 17 |
remove_empty_feeds = True |
| 18 |
cover_url = 'http://www.software.com/images/products/BigOven%20Logo_177_216.JPG' |
| 19 |
max_articles_per_feed = 30 |
| 20 |
needs_subscription = True |
| 21 |
|
| 22 |
conversion_options = {'linearize_tables': True, 'comment': description, 'tags': category, 'publisher': publisher, 'language': language} |
| 23 |
|
| 24 |
def get_browser(self): |
| 25 |
br = BasicNewsRecipe.get_browser(self) |
| 26 |
if self.username is not None and self.password is not None: |
| 27 |
br.open('http://www.bigoven.com/account/login?ReturnUrl=/') |
| 28 |
br.select_form(nr=1) |
| 29 |
br['Email'] = self.username |
| 30 |
br['Password'] = self.password |
| 31 |
br.submit() |
| 32 |
return br |
| 33 |
|
| 34 |
remove_attributes = ['style', 'font'] |
| 35 |
|
| 36 |
def get_article_url(self, article): |
| 37 |
url = article.get('feedburner_origlink', article.get('link', None)) |
| 38 |
front, middle, end = url.partition('comhttp//www.bigoven.com') |
| 39 |
url = front + 'com' + end |
| 40 |
return url |
| 41 |
|
| 42 |
keep_only_tags = [dict(name='div', attrs={'id': ['nosidebar_main']})] |
| 43 |
|
| 44 |
remove_tags_after = [dict(name='div', attrs={'class': ['display-field']})] |
| 45 |
|
| 46 |
remove_tags = [dict(name='ul', attrs={'class': ['tabs']})] |
| 47 |
|
| 48 |
preprocess_regexps = [ |
| 49 |
(re.compile(r'Want detailed nutrition information?', re.DOTALL), lambda match: ''), |
| 50 |
(re.compile(r'\(You could win \$100 in our ', re.DOTALL), lambda match: ''), |
| 51 |
] |
| 52 |
|
| 53 |
def preprocess_html(self, soup): |
| 54 |
for tag in soup.findAll(name='a', text=re.compile(r'.*View Metric.*', re.DOTALL)): |
| 55 |
tag.parent.parent.extract() |
| 56 |
for tag in soup.findAll(text=re.compile(r'.*Try BigOven Pro for Free.*', re.DOTALL)): |
| 57 |
tag.extract() |
| 58 |
for tag in soup.findAll(text=re.compile(r'.*Add my photo of this recipe.*', re.DOTALL)): |
| 59 |
tag.parent.extract() |
| 60 |
for tag in soup.findAll(name='a', text=re.compile(r'.*photo contest.*', re.DOTALL)): |
| 61 |
tag.parent.extract() |
| 62 |
for tag in soup.findAll(name='a', text='Remove ads'): |
| 63 |
tag.parent.parent.extract() |
| 64 |
for tag in soup.findAll(name='ol', attrs={'class': ['recipe-tags']}): |
| 65 |
tag.parent.extract() |
| 66 |
return soup |
| 67 |
|
| 68 |
feeds = [('Recent Raves', 'http://www.bigoven.com/rss/recentraves'), ('Recipe Of The Day', 'http://feeds.feedburner.com/bigovencom-RecipeOfTheDay')] |