Created
February 23, 2015 00:48
-
-
Save h2rd/9c38373161a39cc4077e to your computer and use it in GitHub Desktop.
Dynamic Creation of Item Classes Scrapy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from scrapy.item import DictItem, Field | |
| def create_item_class(class_name, field_list): | |
| fields = {field_name: Field() for field_name in field_list} | |
| return type(class_name, (DictItem,), {'fields': fields}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment