1
我正在构建Web刮板并尝试为实体分配UUID。在MongoDB中分配UUID并检查网页扫描器的重复内容
因为一个实体可以在不同的时间刮,我想最初的UUID存储与从网页
// example document
{
"ent_eid_type": "ABC-123",
"ent_uid_type": "123e4567-aaa-123e456"
}
下面
提取的ID一起的是,对于在找到的每一个id字段上运行的代码被刮掉的物品
# if the current ent_eid_type is a key in mongo...
if db_coll.find({ent_eid_type: ent_eid}).count() > 0:
# return the uid value
ent_uid = db_coll.find({ent_uid_type: ent_uid })
else:
# create a fresh uid
ent_uid = uuid.uuid4()
# store it with the current entity eid as key, and uid as value
db_coll.insert({ent_eid_type: ent_eid, ent_uid_type: ent_uid})
# update the current item with the stored uid for later use
item[ent_uid_type] = ent_uid
控制台正在返回KeyError: <pymongo.cursor.Cursor object at 0x104d41710>
。不知道如何解析光标ent_uid
任何提示/建议表示赞赏!