<s> from scrapy . contrib . spiders import CrawlSpider , Rule <EOL> from scrapy . contrib . linkextractors . sgml import SgmlLinkExtractor <EOL> from scrapy . selector import HtmlXPathSelector <EOL> from openrecipes . items import RecipeItem , RecipeItemLoader <EOL> class NaturallyEllaMixin ( object ) : <EOL> source = '<STR_LIT>' <EOL> def parse_item ( self , response ) : <EOL> hxs = HtmlXPathSelector ( response ) <EOL> base_path = """<STR_LIT>""" <EOL> recipes_scope = hxs . select ( base_path ) <EOL> description_path = '<STR_LIT>' <EOL> image_path = '<STR_LIT>' <EOL> name_path = '<STR_LIT>' <EOL> url_path = '<STR_LIT>' <EOL> date_published_path = '<STR_LIT>' <EOL> author_path = '<STR_LIT>' <EOL> ingredients_path = '<STR_LIT>' <EOL> cook_time_path = '<STR_LIT>' <EOL> prep_time_path = '<STR_LIT>' <EOL> category_path = '<STR_LIT>' <EOL> yield_path = '<STR_LIT>' <EOL> total_time_path = '<STR_LIT>' <EOL> recipes = [ ] <EOL> for recipe_scope in recipes_scope : <EOL> il = RecipeItemLoader ( item = RecipeItem ( ) ) <EOL> il . add_value ( '<STR_LIT:source>' , self . source ) <EOL> il . add_value ( '<STR_LIT:description>' , recipe_scope . select ( description_path ) . extract ( ) ) <EOL> il . add_value ( '<STR_LIT:image>' , recipe_scope . select ( image_path ) . extract ( ) ) <EOL> il . add_value ( '<STR_LIT:name>' , recipe_scope . select ( name_path ) . extract ( ) ) <EOL> il . add_value ( '<STR_LIT:url>' , recipe_scope . select ( url_path ) . extract ( ) ) <EOL> il . add_value ( '<STR_LIT>' , recipe_scope . select ( date_published_path ) . extract ( ) ) <EOL> il . add_value ( '<STR_LIT>' , recipe_scope . select ( author_path ) . extract ( ) ) <EOL> ingredients = [ ] <EOL> ingredient_scopes = recipe_scope . select ( ingredients_path ) <EOL> for ingredient_scope in ingredient_scopes : <EOL> ingredient = ingredient_scope . extract ( ) . strip ( ) <EOL> if ( ingredient ) : <EOL> ingredients . append ( ingredient ) <EOL> il . add_value ( '<STR_LIT>' , ingredients ) <EOL> il . add_value ( '<STR_LIT>' , recipe_scope . select ( cook_time_path ) . extract ( ) ) <EOL> il . add_value ( '<STR_LIT>' , recipe_scope . select ( prep_time_path ) . extract ( ) ) <EOL> il . add_value ( '<STR_LIT>' , recipe_scope . select ( category_path ) . extract ( ) ) <EOL> il . add_value ( '<STR_LIT>' , recipe_scope . select ( yield_path ) . extract ( ) ) <EOL> il . add_value ( '<STR_LIT>' , recipe_scope . select ( total_time_path ) . extract ( ) ) <EOL> recipes . append ( il . load_item ( ) ) <EOL> return recipes <EOL> class NaturallyEllaCrawlSpider ( CrawlSpider , NaturallyEllaMixin ) : <EOL> name = "<STR_LIT>" <EOL> allowed_domains = [ "<STR_LIT>" ] <EOL> start_urls = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] <EOL> rules = ( <EOL> Rule ( SgmlLinkExtractor ( allow = ( '<STR_LIT>' ) ) , <EOL> callback = '<STR_LIT>' ) , <EOL> ) </s>
