Skip to content

Instantly share code, notes, and snippets.

@h2rd
Created February 23, 2015 00:48
Show Gist options
  • Select an option

  • Save h2rd/9c38373161a39cc4077e to your computer and use it in GitHub Desktop.

Select an option

Save h2rd/9c38373161a39cc4077e to your computer and use it in GitHub Desktop.
Dynamic Creation of Item Classes Scrapy
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