-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from ._abstract import AbstractScraper | ||
from ._utils import get_minutes, normalize_string | ||
|
||
|
||
class Epicurious(AbstractScraper): | ||
|
||
@classmethod | ||
def host(self): | ||
return 'epicurious.com' | ||
|
||
def title(self): | ||
return self.soup.find('h1', {'itemprop': 'name'}).get_text() | ||
|
||
def total_time(self): | ||
return get_minutes(self.soup.findAll('p', {'class': 'summary_data'})[-1]) | ||
|
||
def ingredients(self): | ||
ingredients_html = self.soup.findAll('li', {'itemprop': "ingredients"}) | ||
|
||
return [ | ||
normalize_string(ingredient.get_text()) | ||
for ingredient in ingredients_html | ||
] | ||
|
||
def instructions(self): | ||
instructions_html = self.soup.find('div', {'id': 'preparation'}).find_all('p') | ||
|
||
return '\n'.join([ | ||
normalize_string(instruction.get_text()) | ||
for instruction in instructions_html | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import os | ||
import unittest | ||
|
||
from recipe_scrapers.epicurious import Epicurious | ||
|
||
|
||
class TestEpicurious(unittest.TestCase): | ||
def setUp(self): | ||
# tests are run from tests.py | ||
with open(os.path.join( | ||
os.getcwd(), | ||
'recipe_scrapers', | ||
'tests', | ||
'test_data', | ||
'epicurious.html' | ||
)) as file_opened: | ||
self.harvester_class = Epicurious(file_opened, test=True) | ||
|
||
def test_host(self): | ||
self.assertEqual( | ||
'epicurious.com', | ||
self.harvester_class.host() | ||
) | ||
|
||
def test_title(self): | ||
self.assertEqual( | ||
self.harvester_class.title(), | ||
'Poached Eggs in Tomato Sauce with Chickpeas and Feta' | ||
) | ||
|
||
def test_total_time(self): | ||
self.assertEqual( | ||
35, | ||
self.harvester_class.total_time() | ||
) | ||
|
||
def test_ingredients(self): | ||
self.assertListEqual( | ||
[ | ||
'1/4 cup olive oil', | ||
'1 medium onion, finely chopped', | ||
'4 garlic cloves, coarsely chopped', | ||
'2 jalapeños, seeded, finely chopped', | ||
'1 15-ounce can chickpeas, drained', | ||
'2 teaspoons Hungarian sweet paprika', | ||
'1 teaspoon ground cumin', | ||
'1 28-ounce can whole peeled tomatoes, crushed by hand, juices reserved', | ||
'Kosher salt and freshly ground black pepper', | ||
'1 cup coarsely crumbled feta', | ||
'8 large eggs', | ||
'1 tablespoon chopped flat-leaf parsley', | ||
'1 tablespoon chopped fresh cilantro', | ||
'Warm pita bread' | ||
], | ||
self.harvester_class.ingredients() | ||
) | ||
|
||
def test_instructions(self): | ||
return self.assertEqual( | ||
'Preheat oven to 425°F. Heat oil in a large ovenproof skillet over medium-high heat. Add onion, garlic, and jalapeños; cook, stirring occasionally, until onion is soft, about 8 minutes. Add chickpeas, paprika, and cumin and cook for 2 minutes longer.\nAdd crushed tomatoes and their juices. Bring to a boil, reduce heat to medium-low, and simmer, stirring occasionally, until sauce thickens slightly, about 15 minutes. Season to taste with salt and pepper. Sprinkle feta evenly over sauce. Crack eggs one at a time and place over sauce, spacing evenly apart. Transfer skillet to oven and bake until whites are just set but yolks are still runny, 5-8 minutes. Garnish with parsley and cilantro. Serve with pita for dipping.\nPer serving: 358 calories, 22 g fat, 22 g carbohydrates\nNutritional analysis provided by Bon Appétit', | ||
self.harvester_class.instructions() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters