Scrapy: Define items dynamically

前端 未结 5 1389
别跟我提以往
别跟我提以往 2021-02-05 10:23

As I started to learn scrapy, i have come accross a requirement to dynamically build the Item attributes. I\'m just scraping a webpage which has a table structure and I wanted t

5条回答
  •  失恋的感觉
    2021-02-05 10:36

    Use this class:

    class Arbitrary(Item):
        def __setitem__(self, key, value):
            self._values[key] = value
            self.fields[key] = {}
    

提交回复
热议问题