how to implement nested item in scrapy?

后端 未结 2 1310
鱼传尺愫
鱼传尺愫 2020-12-08 10:43

I am scraping some data with complex hierarchical info and need to export the result to json.

I defined the items as

class FamilyItem():
    name =         


        
2条回答
  •  粉色の甜心
    2020-12-08 10:56

    Not sure if there's a way to do nested items in scrapy with classes but arrays work fine. You could do something like this:

    grandson = Grandson(name = 'Grandson', age = 2)
    
    son = Son(name = 'Son', grandsons = [grandson])
    
    item = Item(name = 'Name', son = [son])
    

提交回复
热议问题