例如,我有Scrapy Item:
class QuotetutorialItem(scrapy.Item):
url = scrapy.Field()
country = scrapy.Field()
state = scrapy.Field()
当我生产此物品时,我会按字母顺序获得字段。
如何使字段顺序与类结构中的顺序相同?
答案 0 :(得分:1)
您可以使用以下属性custom_settings
class YourSpiderClass(scrapy.Spider):
name = 'spider_name'
start_urls = ['http://blahblah.com/']
custom_settings = {
'FEED_URI': 'file.csv',
'FEED_FORMAT': 'csv',
'FEED_EXPORT_FIELDS': [
'Url',
'Country',
'State',
],
}
def parse(self, response):
# you actions