【发布时间】:2013-04-15 09:33:07
【问题描述】:
我创建了一个新的蜘蛛来抓取网站。 这个爬虫获取网站上liste的每个视频游戏并为其创建一个对象:
class gameInfos(Item):
title = Field()
desc = Field()
kind = Field()
对于每个游戏,网站都包含一个可变的经销商列表。我得到了对象中的每个经销商:
class buyInfos(Item):
name = Field()
address = Field()
price = Field()
现在,我的问题:
我想将 buyInfos 对象放入 gameInfos 对象中,并且我的 json 文件看起来:
[
{
"title": "BF3",
"desc": "a beautiful game",
"kind" : "FPS",
"buy" :
[
{name : "cdiscount", "address" : "example", "price" : "45 €"},
{name : "amazon", "address" : "example amazon", "price" : "40 €"},
//... other resellers
]
},
{
"title": "COD 42",
"desc": "a game",
"kind" : "FPS",
"buy" :
},
//... other games
]
所以我尝试在我的主对象中创建一个对象。它可以工作,但最后,我只有一个要填充的对象,而我想在我的主对象中创建一些对象。
感谢您的帮助
【问题讨论】: