Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add giallo zafferano to scrapers, closes #28 #29

Merged
merged 3 commits into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ If you are programmer PRs with fixes are warmly welcomed and acknowledged with a
- [http://epicurious.com/](http://epicurious.com/)
- [http://finedininglovers.com/](https://www.finedininglovers.com/)
- [http://foodrepublic.com/](http://foodrepublic.com)
- [http://giallozafferano.it/](http://giallozafferano.it)
- [http://jamieoliver.com/](http://www.jamieoliver.com/)
- [http://mybakingaddiction.com/](http://mybakingaddiction.com/)
- [http://paninihappy.com/](http://paninihappy.com/)
Expand Down
2 changes: 2 additions & 0 deletions recipe_scrapers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .epicurious import Epicurious
from .finedininglovers import FineDiningLovers
from .foodrepublic import FoodRepublic
from .giallozafferano import GialloZafferano
from .hundredandonecookbooks import HundredAndOneCookbooks
from .jamieoliver import JamieOliver
from .mybakingaddiction import MyBakingAddiction
Expand All @@ -33,6 +34,7 @@
Epicurious.host(): Epicurious,
FineDiningLovers.host(): FineDiningLovers,
FoodRepublic.host(): FoodRepublic,
GialloZafferano.host(): GialloZafferano,
HundredAndOneCookbooks.host(): HundredAndOneCookbooks,
JamieOliver.host(): JamieOliver,
MyBakingAddiction.host(): MyBakingAddiction,
Expand Down
35 changes: 35 additions & 0 deletions recipe_scrapers/giallozafferano.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from ._abstract import AbstractScraper
from ._utils import get_minutes, normalize_string
import json


class GialloZafferano(AbstractScraper):

@classmethod
def host(self):
return 'ricette.giallozafferano.it'

def title(self):
return self.soup.find('h1').get_text()

def total_time(self):
return get_minutes(self.soup.find('li', {'class': 'preptime'})) +\
get_minutes(self.soup.find('li', {'class': 'cooktime'}))

def ingredients(self):
ingredients_html = self.soup.findAll('dd', {'class': "ingredient"})

return [
normalize_string(ingredient.get_text())
for ingredient in ingredients_html
]

def instructions(self):
instructions_json = json.loads(
self.soup.find('script', {
'type': 'application/ld+json'}).text).get('recipeInstructions')

return '\n'.join([
normalize_string(instruction)
for instruction in instructions_json
])
Loading