コード例 #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()
コード例 #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
コード例 #3
0
ファイル: scraper.py プロジェクト: azizur77/recipe-scrapers
 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...")
コード例 #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()
コード例 #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...")