3
0

迁移.py 1015 B

12345678910111213141516171819202122232425262728293031323334
  1. from feapder.db.mongodb import MongoDB
  2. class Details:
  3. _to_db = None
  4. _to_db_xs = None
  5. db_name = 'mgp_list'
  6. # 定义mongo链接
  7. @property
  8. def to_db(self):
  9. if not self._to_db:
  10. self._to_db = MongoDB()
  11. return self._to_db
  12. @property
  13. def to_db_xs(self):
  14. if not self._to_db_xs:
  15. self._to_db_xs = MongoDB(port=27001)
  16. return self._to_db_xs
  17. def main(self):
  18. data_lsit = self.to_db.find(self.db_name, {"parser_name": "details"},sort={"date":-1})
  19. for item in data_lsit:
  20. # print(item.get("item").get("publishtime"))
  21. print(item.get("date"))
  22. del item["_id"]
  23. # # print(item)
  24. if item.get("item").get("publishtime") > '2021-12-15 09:12:43':
  25. print(item)
  26. else:
  27. # self.to_db_xs.add(self.db_name, item)
  28. self.to_db.delete(self.db_name, item)
  29. # self.to_db.delete(self.db_name, item)
  30. Details().main()