Python Forum

Full Version: Scrapy-cut: Advanced Cookiecutter Scrapy Templating
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This post is to inquire any references or resources is... any pointers  to the following project scope whilst using cookie cutter framework.

can check it out at https://github.com/3rawkz/scrapy-cut


Please review the git repository. You might get a sense of what I'm trying to accomplish, I literally just threw up that Reba the past half-hour and no I don't feel it's up to a draft completion my question is the following.

 Using Jinja,is it possible have multiple templates but in some sort of dictionary be able to call just one? For example I know the end official documents for cookiecutter I first learned that while creating the cookiecutter-pypackage, the license content is located in one text file, of which using else if statement creates a dictionary which is defined  in the json file... Is similar process for python template? Or is it creating a text file with the python code and then figuring out how to do code to create the spider?

Secondly, if I refer you to the "demo" spider code snippet...

yield {

           'name': "{{cookiecutter.item_name_selector}}",

           'event': "{{cookiecutter.item_event_selector}}",

           'vidurl': "{{cookiecutter.item_vidurl_selector}}",

           'tags': "{{cookiecutter.item_tags_selector}}",


           }
 

As you can Imagine... (or if you are slightly familiar with cookiecutter would have check out the json file), the variables are defined and in this scrapy project not using items.py for the sake of starting easy... In the given code snip while using cookicutter... Is there some way I can loop to input x desired amount of items and the "Item selector" to add as many as I need?
Bad news to name a dictionary yield, that is reserved for generators
(Feb-02-2017, 07:51 PM)Larz60+ Wrote: [ -> ]Bad news to name a dictionary yield, that is reserved for generators

Larz, youre always the first to ever reply... your dedication on here is admirable! MORE BADGES 4 U! lol.. And yes! that correct... The block of code to im referring to in my Second question, as to the how-to have a loop to create the the yield is just the item names an the responsee selector, inside the actual spider the yield {....} stays... like had-coded