pipelines.py 中的关键代码为:
if db.mycollection.find({"ip":item["ip"]}):
print "{} has already existed.".format(item["ip"])
print db.mycollection.find()
else:
db.mycollection.insert_one(data)
print db.mycollection.count({})
执行的结果总是:
120.25.164.134 has already existed.
<pymongo.cursor.Cursor object at 0x0000000005B330F0>
……
提示我抓取到的每一条数据都是存在的,我的 mycollection 聚集中最开始是空的,为什么会出现这种情况呢?
if db.mycollection.find({"ip":item["ip"]}):
print "{} has already existed.".format(item["ip"])
print db.mycollection.find()
else:
db.mycollection.insert_one(data)
print db.mycollection.count({})
执行的结果总是:
120.25.164.134 has already existed.
<pymongo.cursor.Cursor object at 0x0000000005B330F0>
……
提示我抓取到的每一条数据都是存在的,我的 mycollection 聚集中最开始是空的,为什么会出现这种情况呢?