Exemple #1
0
 def process_recipe_from_url(self, url):
     '''
     Saves recipe info in DB from a given url
     :param url: Pass the url
     :return:
     '''
     try:
         scraper = recipe_scrapers.scrape_me(url)
         recipe_obj = {
             'title': scraper.title(),
             'ingredients': scraper.ingredients(),
             'instructions': scraper.instructions(),
             'total_time': scraper.total_time(),
             'yields': scraper.yields(),
             'external_url': url,
             'host_image_url': scraper.image(),
             'host_author': scraper.author(),
             'host_ratings': scraper.ratings(),
             'language': scraper.language()
         }
         Recipe.create(**recipe_obj)
     except Exception as e:
         logging.error(e, exc_info=True)
         return str(e)