12345678910111213141516171819202122232425262728293031323334 |
- from feapder.db.mongodb import MongoDB
- class Details:
- _to_db = None
- _to_db_xs = None
- db_name = 'mgp_list'
- # 定义mongo链接
- @property
- def to_db(self):
- if not self._to_db:
- self._to_db = MongoDB()
- return self._to_db
- @property
- def to_db_xs(self):
- if not self._to_db_xs:
- self._to_db_xs = MongoDB(port=27001)
- return self._to_db_xs
- def main(self):
- data_lsit = self.to_db.find(self.db_name, {"parser_name": "details"},sort={"date":-1})
- for item in data_lsit:
- # print(item.get("item").get("publishtime"))
- print(item.get("date"))
- del item["_id"]
- # # print(item)
- if item.get("item").get("publishtime") > '2021-12-15 09:12:43':
- print(item)
- else:
- # self.to_db_xs.add(self.db_name, item)
- self.to_db.delete(self.db_name, item)
- # self.to_db.delete(self.db_name, item)
- Details().main()
|