Exemplo n.º 1
0
def reprocess_recipe(recipe):
    recipe_model = ScraperRecipe(recipe['recipe_name'])

    recipe_model.source = recipe['source']
    recipe_model.url = recipe['_id']
    recipe_model.ingredients = [ ScraperIngredient(ingredient) \
        for ingredient in recipe['ingredients'] ]

    recipe_model.save()
Exemplo n.º 2
0
 def get_recipes_from_list_page(self, list_page):
     recipe_links = list_page.cssselect(self.RECIPE_LINK_SELECTOR)
     for recipe_link in recipe_links:
         recipe_name = self.format_name(recipe_link.text_content())
         recipe_href = recipe_link.get('href')
         if self.RELATIVE_URLS:
             recipe_url = urltools.rel_to_abs(self.SOURCE_URL, recipe_href)
         else:
             recipe_url = recipe_href
         recipe = ScraperRecipe(recipe_name,
                                source=self.SOURCE_NAME,
                                url=recipe_url)
         yield recipe
Exemplo n.º 3
0
 def get_recipes(self, start_point=None):
     """Gets a full list of recipes for this source
     Returns a list of ScraperRecipes"""
     for recipe_list_url in self.get_recipe_list_urls(start_point):
         self.list_page = self.parse(recipe_list_url)
         if self.list_page is not None:
             for recipe in self.get_recipes_from_list_page(self.list_page):
                 self.logger.debug("found %s at %s" % 
                     (recipe.recipe_name, recipe.url) )
                 if self.refresh or not ScraperRecipe.recipe_in_db(recipe.url):
                     yield recipe
                 else:
                     self.logger.debug("Recipe already in database, skipping...")
Exemplo n.º 4
0
def reprocess_recipe(recipe):
    recipe_model = ScraperRecipe(recipe['recipe_name'])

    recipe_model.source = recipe['source']
    recipe_model.url = recipe['_id']
    recipe_model.ingredients = [ ScraperIngredient(ingredient) \
        for ingredient in recipe['ingredients'] ]

    recipe_model.save()
Exemplo n.º 5
0
 def get_recipes(self, start_point=None):
     """Gets a full list of recipes for this source
     Returns a list of ScraperRecipes"""
     for recipe_list_url in self.get_recipe_list_urls(start_point):
         self.list_page = self.parse(recipe_list_url)
         if self.list_page is not None:
             for recipe in self.get_recipes_from_list_page(self.list_page):
                 self.logger.debug("found %s at %s" %
                                   (recipe.recipe_name, recipe.url))
                 if self.refresh or not ScraperRecipe.recipe_in_db(
                         recipe.url):
                     yield recipe
                 else:
                     self.logger.debug(
                         "Recipe already in database, skipping...")