def __init__(self, **arg): self.head = { "device": { "type": setting.DEVICE_TYPE, "id": setting.DEVICE_ID, "mac": '', "api_key": '' }, "command": { "action": '', "version": '' }, "body": { "taskstats": { "time": time.time(), "status": '' }, "get_tasks": '', "tasks": '', "data": "", "client_status": '', "proxy_data": '', "cookie_data": '' } } self.db_obj = db_oprate.collection_db() #操作数据库对象
def threading_get(): while True: obj_db = db_oprate.collection_db() # 操作数据库对象 tb = obj_db.choice_crawl_table() # 进入抓取任务表 task_data = obj_db.find_one(tb, {}) if task_data: obj_id = task_data['body'] body = obj_db.gridfs_get_crawldata(obj_id) # 读出gridfs # obj_db.gridfs_del_crawldata(obj_id) # 将body从文档中删除 body = eval(body) # 还原body task_data['body'] = body #print(body) print('get_data') time.sleep(1)
def __init__(self): self.connect_server_process = '' self.db_obj = db_oprate.collection_db() # 操作数据库对象
from excutor_doc import db_oprate db_obj = db_oprate.collection_db() #操作数据库对象 data_tb = db_obj.choice_data_table() # 切换到存储数据表 data = db_obj.find_modify(data_tb, {'upload_flag': 0}, {'$set': { 'upload_flag': 0 }}) obj_id = data['body'] # 得到存储数据的id body = db_obj.gridfs_get_data(obj_id) # 从文档中读出body字段{'result':'',data:''} body = eval(body) # 还原body data['result'] = body['result'] data['data'] = body['data'] print(data['data'])
def __init__(self): self.db_obj = db_oprate.collection_db() # 操作数据库对象