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,db='editor') return self._to_db_xs def main(self,page): menus_list = [] data = self.to_db_xs.find("luaconfig",{"modifyuser":"maguopeng","param_common":{"$elemMatch": {"$regex": "广东省政府采购网", "$options": "$i"}}}) # print(data) for item in data: # print(item) channls = item.get("param_common")[2] code = item.get("code") href = item.get("param_common")[11] print("Menu"+"(",f"'{channls}',",f"'{code}',\n",f"'{href}',",page,"),") # menus_list.append(f'''Menu({channls},{code},{href},{page})''') # print(menus_list) Details().main(2)