diff --git a/main.py b/main.py index 559b14e..2a6b88c 100644 --- a/main.py +++ b/main.py @@ -46,12 +46,12 @@ def recipe(): try: recipe = scrape_recipe(url) if not recipe: - return render_template('unsupported.html', domain=domain) + return render_template('unsupported.html', domain=domain), 501 return render_template('recipe.html', recipe=recipe) except: logging.exception(url) - return render_template('parse_error.html', domain=domain) + return render_template('parse_error.html', domain=domain), 418 @app.route('/supported-websites') def supported_websites(): diff --git a/parsers/essenundtriken.py b/parsers/essenundtriken.py index f43a3a3..5c24830 100644 --- a/parsers/essenundtriken.py +++ b/parsers/essenundtriken.py @@ -10,8 +10,8 @@ class EssenUndTrinken(Recipe): recipe['name'] = d['name'] recipe['description'] = d.get('description', '') recipe['ingredients'] = d['recipeIngredient'] - recipe['instructions'] = self.cleanhtml(d['recipeInstructions']).split('\n') - recipe['image'] = d['image'] + recipe['instructions'] = d['recipeInstructions'] + recipe['image'] = d['image'][0]['url'] return recipe @@ -24,13 +24,9 @@ class EssenUndTrinken(Recipe): result = soup.find_all('script', {'type': 'application/ld+json'}) - d = json.loads(result[1].contents[0]) + d = json.loads(result[0].contents[0])[0] parsed_recipe = self.get_json_recipe(d) recipe.update(parsed_recipe) - return recipe - - def cleanhtml(self, txt): - cleanr = re.compile('<.*?>') - return re.sub(cleanr, '', txt.lstrip(" \n")) \ No newline at end of file + return recipe \ No newline at end of file