fixes issue-17: adds thatlowcarblife.com
This commit is contained in:
parent
e932be7d92
commit
61acbb0005
2 changed files with 42 additions and 1 deletions
|
@ -15,6 +15,7 @@ from parsers.thewoksoflife import Thewoksoflife
|
|||
from parsers.glebekitchen import GlebeKitchen
|
||||
from parsers.akispetretzikis import AkisPetretzikis
|
||||
from parsers.hervecuisine import Hervecuisine
|
||||
from parsers.thatlowcarblife import ThatLowCarbLife
|
||||
|
||||
# Must exclude the "www" portion of the URL
|
||||
PARSERS = {
|
||||
|
@ -33,7 +34,8 @@ PARSERS = {
|
|||
'thewoksoflife.com': Thewoksoflife,
|
||||
'glebekitchen.com': GlebeKitchen,
|
||||
'akispetretzikis.com': AkisPetretzikis,
|
||||
'hervecuisine.com': Hervecuisine
|
||||
'hervecuisine.com': Hervecuisine,
|
||||
'thatlowcarblife.com': ThatLowCarbLife,
|
||||
}
|
||||
|
||||
def getParser(domain):
|
||||
|
|
39
parsers/thatlowcarblife.py
Normal file
39
parsers/thatlowcarblife.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
from parsers.recipe import Recipe
|
||||
|
||||
class ThatLowCarbLife(Recipe):
|
||||
|
||||
def scrape_recipe(self, soup):
|
||||
recipe = {}
|
||||
|
||||
name = soup.find('h2', {'class': 'mv-create-title'})
|
||||
recipe['name'] = name.contents[0]
|
||||
|
||||
description = soup.find('div', {'class': 'mv-create-description'})
|
||||
recipe['description'] = description.contents[0].text
|
||||
|
||||
image = soup.find('header', {'class': 'mv-create-header'})
|
||||
recipe['image'] = image.contents[1]['src']
|
||||
|
||||
recipe['ingredients'] = []
|
||||
ingredients = soup.find('div', {'class': 'mv-create-ingredients'}).find('ul').findChildren('li')
|
||||
for li in ingredients:
|
||||
recipe['ingredients'].append(li.text)
|
||||
|
||||
recipe['instructions'] = []
|
||||
instructions = soup.find('div', {'class': 'mv-create-instructions'}).find('ol').findChildren('li')
|
||||
for li in instructions:
|
||||
recipe['instructions'].append(li.text)
|
||||
|
||||
return recipe
|
||||
|
||||
|
||||
def Parse(self, url):
|
||||
recipe = {}
|
||||
recipe['url'] = url
|
||||
recipe['source'] = 'thatlowcarblife.com'
|
||||
|
||||
soup = self.fetch_soup(url)
|
||||
parsed_recipe = self.scrape_recipe(soup)
|
||||
recipe.update(parsed_recipe)
|
||||
|
||||
return recipe
|
Loading…
Reference in a new issue