def update_to_db(self, information, gs_basic_id): insert_flag, update_flag = 0, 0 remark = 0 total = len(information) try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB(HOST, USER, PASSWD, DB, PORT) for key in information.keys(): number, types, content = information[key][0], information[key][1], information[key][2] date, pub_date, gov_dept = information[key][3], information[key][4], information[key][5] count = cursor.execute(select_punish, (gs_basic_id, number)) if count == 0: m = hashlib.md5() m.update(str(number)) id = m.hexdigest() updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute(punish_string, ( gs_basic_id, id, number, types, content, date, pub_date, gov_dept, updated_time)) insert_flag += rows_count connect.commit() except Exception, e: remark = 100000006 logging.error("punish error:%s" % e)
def update_to_db(self, info, gs_basic_id): HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB(HOST, USER, PASSWD, DB, PORT) insert_flag, update_flag = 0, 0 flag = 0 total = len(info) try: for key in info.keys(): executor, stock_amount, court, notice_no = info[key][0], info[ key][1], info[key][2], info[key][3] status, items, rule_no, enforce_no = info[key][4], info[key][ 5], info[key][6], info[key][7] cert_cate, cert_code, start_date, end_date = info[key][ 8], info[key][9], info[key][10], info[key][11] period, pub_date = info[key][12], info[key][13] count = cursor.execute(select_freeze, (gs_basic_id, rule_no, executor)) if count == 0: updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute( freeze_string, (gs_basic_id, executor, stock_amount, court, notice_no, status, items, rule_no, enforce_no, cert_cate, cert_code, start_date, end_date, period, pub_date, updated_time)) insert_flag += rows_count connect.commit() except Exception, e: logging.error("freeze error: %s" % e) flag = 100000006
def update_to_db(self, info, gs_basic_id): HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB(HOST, USER, PASSWD, DB, PORT) insert_flag, update_flag = 0, 0 flag = 0 total = len(info) try: for key in info.keys(): name = info[key][0] code = info[key][1] ccode = info[key][2] gov_dept = info[key][3] m = hashlib.md5() m.update(str(gs_basic_id) + str(name)) id = m.hexdigest() count = cursor.execute(select_string, (id, gs_basic_id)) if count == 0: updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute(branch_string, (gs_basic_id, id, code, ccode, name, gov_dept, updated_time)) insert_flag += rows_count connect.commit() except Exception, e: flag = 100000006 logging.error('branch error: %s' % e)
def update_to_db(self, information, gs_basic_id): insert_flag, update_flag = 0, 0 remark = 0 total = len(information) try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB( HOST, USER, PASSWD, DB, PORT) for key in information.keys(): person_name = str(information[key][0]) position = str(information[key][1]) rows = cursor.execute(select_string, (gs_basic_id, person_name, position)) if int(rows) == 1: gs_clear_id = cursor.fetchall()[0][0] updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) count = cursor.execute( update_string, (gs_clear_id, updated_time, gs_clear_id)) update_flag += count connect.commit() elif rows == 0: updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) count = cursor.execute( insert_string, (gs_basic_id, person_name, position, updated_time)) insert_flag += count connect.commit() except Exception, e: cursor.close() connect.close() remark = 100000006 logging.error("clear error: %s" % e)
def report_main(org, id, seqid, regno, gs_basic_id,gs_py_id): remark = 0 total, insert = 0, 0 try: types = config.key_params["report"] url = config.main_branch_url + config.branch_params.format(types, org, id, seqid,regno) object = Report(url, headers, org, id, seqid,regno,gs_basic_id,gs_py_id) HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB(HOST, USER, PASSWD, DB, PORT) #从数据库中选择成立日期 now_year = time.localtime(time.time())[0] select_string = select_basic_year % gs_basic_id cursor.execute(select_string) reg_date = cursor.fetchall()[0][0] if reg_date == None or reg_date == '': logging.info("数据库中无成立日期") else: reg_year = str(reg_date)[0:4] if now_year == int(reg_year): flag = -1 logging.info("该企业无年报") else: info, flag = object.get_report_href() if flag == 1: if len(info) == 0: flag = -1 else: total, insert = get_all_report_info(info, object, cursor, connect,gs_basic_id) else: logging.info("打开网页链接失败") except Exception, e: flag = 100000005 logging.error("error:%s" % e)
def update_to_db(self, info,gs_basic_id): update_flag, insert_flag = 0, 0 remark = 0 total = len(info) try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB(HOST, USER, PASSWD, DB, PORT) for key in info.keys(): types, in_reason, in_date = info[key][0], info[key][1], info[key][2] out_reason, out_date, gov_dept = info[key][3], info[key][4], info[key][5] count = cursor.execute(select_except, (gs_basic_id, in_date)) if count == 0: updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute(except_string, ( gs_basic_id, types, in_reason, in_date, out_reason, out_date, gov_dept, updated_time)) insert_flag += rows_count connect.commit() elif count == 1: gs_except_id = cursor.fetchall()[0][0] updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute(update_except, ( gs_except_id, types, in_reason, out_reason, out_date, gov_dept, updated_time, gs_except_id)) update_flag += rows_count connect.commit() except Exception, e: remark = 100000006 logging.error("except error: %s" % e)
def update_to_db(self, info, gs_basic_id): remark = 0 try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB( HOST, USER, PASSWD, DB, PORT) name, ccode, status, types = info[0], info[1], info[2], info[3] legal_person, reg_date, appr_date, reg_amount = info[4], info[ 5], info[6], info[7] start_date, end_date, reg_zone, reg_address = info[8], info[ 9], info[10], info[11] scope, del_date = info[12], info[13] updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) row_count = cursor.execute( update_string, (gs_basic_id, name, ccode, status, types, legal_person, reg_date, appr_date, reg_amount, start_date, end_date, reg_zone, reg_address, scope, del_date, updated_time, gs_basic_id)) connect.commit() except Exception, e: cursor.close() connect.close() logging.error("basic error:%s" % e) remark = 100000006
def get_info(code, ccode, gs_basic_id): # 正则匹配判断code 或者ccode 根据哪个进行查询 pattern = re.compile(r'^9.*') result1 = re.findall(pattern, code) result2 = re.findall(pattern, ccode) if len(result1) == 0 and len(result2) == 0: string = code elif len(result1) == 1: string = code elif len(result2) == 1: string = ccode else: pass idname, flag, cookies = get_keyid(string) flag, items = get_search_info(idname, cookies) if flag == 1: org, id, seq_id, name = get_keyword(items) elif flag == 100000003: idname, flag, cookies = get_keyid(string) flag, items = get_search_info(idname, cookies) if flag == 1: org, id, seq_id, name = get_keyword(items) elif flag == 100000003: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB( HOST, USER, PASSWD, DB, PORT) select_string = select_name % gs_basic_id cursor.execute(select_string) name = cursor.fetchall()[0][0] name = deal_html_code.remove_space(name) cursor.close() connect.close() idname, flag, cookies = get_keyid(name) flag, items = get_search_info(idname, cookies) org, id, seq_id, se_name = get_keyword(items) # 用来判断数据库中的公司名字跟搜索到的名字是否一致 if name != se_name: flag = 100000003 org, id, seq_id = 0, 0, 0 print_info(org, id, seq_id, flag)
def update_to_db(self,info,gs_basic_id): insert_flag,update_flag = 0,0 flag = 0 total = len(info) try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB(HOST, USER, PASSWD, DB, PORT) for key in info.keys(): content_before, content_after = info[key][0], info[key][1] change_date, item = info[key][2], info[key][3] types = '变更' updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) count = cursor.execute(select_string,(gs_basic_id,item,change_date)) if count == 0: source = 0 row_count = cursor.execute(insert_string, ( gs_basic_id, types, item, content_before, content_after, change_date,source,updated_time)) insert_flag += row_count connect.commit() elif int(count) >= 1: remark = 0 for gs_basic_id, content in cursor.fetchall(): if content == content_after: remark = 1 break if remark == 0: row_count = cursor.execute(insert_string, ( gs_basic_id, types, item, content_before, content_after, change_date, updated_time)) insert_flag += row_count connect.commit() except Exception, e: flag = 100000006 logging.error("change error :%s " % e)
def update_to_db(self, information, gs_basic_id): insert_flag, update_flag = 0, 0 flag = 0 total = len(information) try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB( HOST, USER, PASSWD, DB, PORT) for key in information.keys(): types, result = information[key][0], information[key][1] check_date, gov_dept = information[key][2], information[key][3] count = cursor.execute(select_check, (gs_basic_id, check_date, types)) if count == 0: updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute( check_string, (gs_basic_id, types, result, check_date, gov_dept, updated_time)) insert_flag += rows_count connect.commit() except Exception, e: cursor.close() connect.close() flag = 100000006 logging.error("check error: %s" % e)
def update_to_db(self, info, gs_basic_id): insert_flag, update_flag = 0, 0 remark = 0 total = len(info) source = 0 try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB(HOST, USER, PASSWD, DB, PORT) for key in info.keys(): name, code, filename, start_date = info[key][0], info[key][1], info[key][2], info[key][3] end_date, content, gov_dept = info[key][4], info[key][5], info[key][6] status = info[key][7] count = cursor.execute(select_string, (gs_basic_id, filename, code, start_date, end_date)) m = hashlib.md5() m.update(code) id = m.hexdigest() if count == 0: updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute(permit_string, ( gs_basic_id, id, name, code, filename, start_date, end_date, content, gov_dept, status, source, updated_time)) insert_flag += rows_count connect.commit() except Exception, e: cursor.close() connect.close() remark = 100000006 logging.error("permit error: %s" % e)
def update_to_db(self, info, gs_basic_id): insert_flag, update_flag = 0, 0 remark = 0 total = len(info) try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB( HOST, USER, PASSWD, DB, PORT) for key in info.keys(): equityNo, pledgor, pledBLicNo = info[key][0], info[key][ 1], info[key][2] impAm, impOrg, impOrgBLicNo = info[key][3], info[key][4], info[ key][5] equPleDate, publicDate, type = info[key][6], info[key][ 7], info[key][8] count = cursor.execute(select_stock, (gs_basic_id, equityNo)) if count == 0: updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute( stock_string, (gs_basic_id, equityNo, pledgor, pledBLicNo, impAm, impOrg, impOrgBLicNo, equPleDate, publicDate, type, updated_time)) insert_flag += rows_count connect.commit() elif int(count) == 1: # print equityNo gs_stock_id = cursor.fetchall()[0][0] updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute( update_stock, (gs_basic_id, pledgor, pledBLicNo, impAm, impOrg, impOrgBLicNo, equPleDate, publicDate, type, updated_time, gs_stock_id)) # print rows_count update_flag += rows_count connect.commit() except Exception, e: cursor.close() connect.close() remark = 100000001 # print "stock error:", e logging.error("stock error: %s" % e)
def main(): Log().found_log(unique_id,user_id) insert_flag, update_flag = 0, 0 try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB(HOST, USER, PASSWD, DB, PORT) string = keyword idname, flag, cookies = get_keyid(string) if flag == 1: flag, items = get_search_info(idname, cookies) info = get_keyword(items) if flag ==1: flag, insert_flag, update_flag = insert_search(keyword, user_id, info, cursor, connect) except Exception, e: flag = 100000005 logging.error("unknow error:%s" % e)
def update_to_db(self, info, gs_basic_id): update_flag, insert_flag = 0, 0 mort_flag = 0 totalinfo = len(info) try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB( HOST, USER, PASSWD, DB, PORT) for key in info.keys(): code, dates, dept, amount = info[key][0], info[key][1], info[ key][2], info[key][3] status, cates, period, ranges, remark = info[key][4], info[key][5], info[key][6], info[key][7], \ info[key][8] cancel_cause = info[key][9] person_info = info[key][10] goods_info = info[key][11] count = cursor.execute(select_mort, (gs_basic_id, code)) if count == 0: m = hashlib.md5() m.update(code) id = m.hexdigest() updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) flag = cursor.execute( mort_string, (gs_basic_id, id, code, dates, dept, amount, status, cates, period, ranges, remark, cancel_cause, updated_time)) gs_mort_id = connect.insert_id() insert_flag += flag connect.commit() elif int(count) == 1: gs_mort_id = cursor.fetchall()[0][0] updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) flag = cursor.execute( update_mort, (gs_mort_id, dates, dept, amount, status, cates, period, ranges, remark, cancel_cause, updated_time, gs_mort_id)) update_flag += flag connect.commit() self.update_goods(gs_mort_id, gs_basic_id, cursor, connect, goods_info) self.update_person(gs_mort_id, gs_basic_id, cursor, connect, person_info) except Exception, e: # print e logging.info('mort error :%s' % e) mort_flag = 100000006
def update_to_db(self, info, gs_basic_id): insert_flag, update_flag = 0, 0 flag = 0 total = len(info) try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB( HOST, USER, PASSWD, DB, PORT) for key in info.keys(): ia_zch, ia_flh, ia_zcgg = info[key][0], info[key][1], info[ key][2] ia_servicelist, ia_zyqqx, ia_zcdate = info[key][3], info[key][ 4], info[key][5] ia_img_url = info[key][6] select_string = select_brand % ia_zch count = cursor.execute(select_string) if count == 0: updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute( brand_string, (gs_basic_id, ia_zch, ia_flh, ia_zcgg, ia_servicelist, ia_zyqqx, ia_zcdate, ia_img_url, updated_time)) insert_flag += rows_count connect.commit() elif count == 1: gs_brand_id = cursor.fetchall()[0][0] updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute( update_brand, (gs_brand_id, gs_basic_id, ia_flh, ia_zcgg, ia_servicelist, ia_zyqqx, ia_zcdate, ia_img_url, updated_time, gs_brand_id)) update_flag += rows_count connect.commit() except Exception, e: flag = 100000006 logging.error("brand error: %s" % e)
def update_to_db(self, info, gs_basic_id): cate = 0 insert_flag, update_flag = 0, 0 remark = 0 total = len(info) try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB( HOST, USER, PASSWD, DB, PORT) string = update_share % gs_basic_id cursor.execute(string) connect.commit() cursor.close() connect.close() HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB( HOST, USER, PASSWD, DB, PORT) for key in info.keys(): name, license_code, license_type = info[key][0], info[key][ 1], info[key][2] types, ra_date, ra_ways, true_amount = info[key][3], info[key][ 4], info[key][5], info[key][6] reg_amount, ta_ways, ta_date = info[key][7], info[key][ 8], info[key][9] country, address = info[key][10], info[key][11] iv_basic_id = 0 if name != '' or name != None: pattern = re.compile('.*公司.*|.*中心.*|.*集团.*|.*企业.*') result = re.findall(pattern, name) if len(result) == 0: iv_basic_id = 0 else: select_unique = select_name % name number = cursor.execute(select_unique) if number == 0: iv_basic_id = 0 elif int(number) == 1: iv_basic_id = cursor.fechall[0][0] else: iv_basic_id = 0 count = cursor.execute(select_string, (gs_basic_id, name, types, cate)) if count == 0: updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute( share_string, (gs_basic_id, name, cate, types, license_type, license_code, ra_date, ra_ways, true_amount, reg_amount, ta_ways, ta_date, country, address, iv_basic_id, updated_time)) insert_flag += rows_count connect.commit() elif int(count) == 1: updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) gs_shareholder_id = cursor.fetchall()[0][0] cursor.execute( update_quit, (updated_time, gs_shareholder_id, gs_basic_id)) connect.commit() except Exception, e: remark = 100000006 logging.error("shareholder error:%s" % e)
def update_to_db(self, information, gs_basic_id): insert_flag, update_flag = 0, 0 remark = 0 total = len(information) try: HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB( HOST, USER, PASSWD, DB, PORT) string = update_string % gs_basic_id cursor.execute(string) connect.commit() cursor.close() connect.close() HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT connect, cursor = Connect_to_DB().ConnectDB( HOST, USER, PASSWD, DB, PORT) for key in information.keys(): name = str(information[key][0]) position = information[key][1] rows = cursor.execute(select_string, (gs_basic_id, name)) # print name,position if int(rows) >= 1: # gs_person_id = cursor.fetchall()[0][0] sign = 0 for gs_person_id, pos in cursor.fetchall(): if pos == position: sign = 1 updated_time = time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime(time.time())) count = cursor.execute( update_quit, (updated_time, gs_basic_id, gs_person_id)) connect.commit() # update_flag += count elif pos == None and position != None: updated_time = time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime(time.time())) count = cursor.execute( person_string, (gs_person_id, position, updated_time, gs_person_id)) update_flag += count connect.commit() sign = 0 if sign == 0: source = 1 updated_time = time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime(time.time())) count = cursor.execute(insert_string, (gs_basic_id, name, position, source, updated_time)) insert_flag += count connect.commit() else: pass elif rows == 0: source = 1 updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) count = cursor.execute( insert_string, (gs_basic_id, name, position, source, updated_time)) insert_flag += count connect.commit() except Exception, e: remark = 100000006 logging.error("person error: %s" % e)