def main(url, year, gs_basic_id, province): 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) flag = update_report_main(gs_basic_id, year, cursor, connect, url, province) string = '%s:' % year + str(flag) logging.info(string) print string except Exception, e: logging.error('report error:%s' % e)
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, value in info.iteritems(): ia_zch, ia_flh, ia_zcgg = value["ia_zch"], info["ia_flh"], value["ia_zcgg"] ia_servicelist, ia_zyqqx, ia_zcdate = info["ia_servicelist"], info["ia_zyqqx"], info["ia_zcdate"] ia_img_url = info["ia_img"] 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,gs_basic_id, information): insert_flag, update_flag = 0, 0 remark = 0 total = len(information) logging.info("clear error:%s"%total) 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, (person_name, position, gs_basic_id)) 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: remark = 100000006 logging.error("clear error: %s" % e)
def update_to_db(self, gs_basic_id, information): 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(): executor, stock_amount, court, notice_no = information[key][0], information[key][1], information[key][2], \ information[key][3] status, items, rule_no, enforce_no = information[key][4], information[key][5], information[key][6], \ information[key][7] cert_cate, cert_code, start_date, end_date = information[key][8], information[key][9], information[key][10], \ information[key][11] period, pub_date = information[key][12], information[key][13] count = cursor.execute(select_freeze, (gs_basic_id, rule_no)) 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: cursor.close() connect.close() logging.error("freeze error: %s" % e) flag = 100000006
def update_to_db( self,gs_basic_id, information): insert_flag, update_flag = 0, 0 remark = 0 total = len(information) logging.info("stock total:%s"%total) 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(): equityNo, pledgor, pledBLicNo = information[key][0], information[key][1], information[key][2] impAm, impOrg, impOrgBLicNo = information[key][3], information[key][4], information[key][5] equPleDate, publicDate, type = information[key][6], information[key][7], information[key][8] count = cursor.execute(select_stock, (gs_basic_id, equityNo)) # print count 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: 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)) update_flag += rows_count connect.commit() except Exception, e: remark = 100000006 logging.error("stock 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) logging.info('change total:%s' % total) try: for key in info.keys(): types, change_date = info[key][0], info[key][1] item, content_before, content_after = info[key][2], info[key][3], info[key][4] 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 count >= 1: remark = 0 for gs_basic_id, content in cursor.fetchall(): if content == content_after: remark = 1 break if remark == 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() except Exception, e: print e flag = 100000006 logging.error("change error :%s " % e)
def update_to_db(self,gs_basic_id,information): update_flag, insert_flag = 0, 0 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) for key in information.keys(): types, in_reason, in_date = information[key][0], information[key][1], information[key][2] out_reason, out_date, gov_dept = information[key][3], information[key][4], information[key][5] count = cursor.execute(select_black, (gs_basic_id, in_date,in_reason)) if count == 0: updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) rows_count = cursor.execute(black_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_black, ( 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): 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, value in info.iteritems(): name, code, filename, start_date = value["name"], value["code"], value["filename"], value["start_date"] end_date, content, gov_dept = value["end_date"], value["content"], value["gov_dept"] status = value["status"] count = cursor.execute(select_string, (gs_basic_id, filename, code, start_date, end_date)) id = '' 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 last_request(challenge, validate, code, ccode, cookies): 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 url, company, history_name, flag = get_url_info(challenge, validate, string, cookies) if flag == 100000003: challenge, validate, cookies = loop_break_password() if cookies == None: flag = 100000001 elif challenge == None or validate == None: flag = 100000002 else: 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 = remove_symbol(name) cursor.close() connect.close() url, company, history_name, flag = get_url_info( challenge, validate, str(name), cookies) if flag == 100000003: url, company, history_name = None, None, None else: if name != company: url, company, history_name = None, None, None return url, company, history_name, flag
def main(): Log().found_log(gs_py_id, 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) flag, recordstotal, update_total, insert_total = update_branch3( cursor, connect, gs_basic_id, gs_py_id, select_black_py, update_black_py, Black, "black") cursor.close() connect.close() info = { "flag": 0, "total": 0, "update": 0, "insert": 0, "perpage": 0, "totalpage": 0 } info["flag"] = int(flag) info["total"] = int(recordstotal) info["update"] = int(update_total) info["insert"] = int(insert_total) print info
def update_to_db(self,info,gs_basic_id): insert_flag = 0 update_flag = 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(): name,code,gov_dept = info[key][0],info[key][1],info[key][2] 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, name, gov_dept, updated_time)) insert_flag += rows_count connect.commit() except Exception,e: logging.info("update branch error:%s"%e) flag = 100000006
def upadte_to_db(self, info, gs_basic_id): 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, types, reg_amount = info[key][0], info[key][1], info[key][2] ra_ways, ra_date, true_amount = info[key][3], info[key][4], info[key][5] ta_ways, ta_date = info[key][6], info[key][7] count = cursor.execute(select_string, (gs_basic_id, name, types)) if int(count) == 1: gs_shareholder_id = cursor.fetchall()[0][0] updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) cursor.execute(insert_string, ( gs_shareholder_id, name, types, reg_amount, ra_ways, ra_date, true_amount, ta_ways, ta_date, updated_time)) # insert_flag += rows_count connect.commit() else: pass except Exception, e: logging.info("update branch error:%s" % e) flag = 100000006
def main(gs_py_id, gs_basic_id, data, province): Log().found_log(gs_py_id, gs_basic_id) 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) info = Mort().name(data, province) flag, total, insert_flag, update_flag = Mort().update_to_db( gs_py_id, cursor, connect, gs_basic_id, info) flag = Judge_status().judge(flag, total) string = 'mort:' + str(flag) + '||' + str(total) + '||' + str( insert_flag) + '||' + str(update_flag) print string if flag == -1: pass else: updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) cursor.execute(update_mort_py, (gs_py_id, flag, updated_time, gs_py_id)) connect.commit() except Exception, e: logging.error("mort error :%s" % e)
def get_info(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 info, flag = get_list(string) if 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_symbol(name) cursor.close() connect.close() info, flag = get_list(name) return info, flag
def update_to_db(self, info, gs_basic_id): # types = '抽查' insert_flag = 0 update_flag = 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(): check_date, gov_dept, result = info[key][0], info[key][1], info[key][2] types = info[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: print e logging.error("check error: %s" % e) flag = 100000006
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, singledata in info.iteritems(): value = singledata[0] code, dates, dept, amount = value["code"], value[ "dates"], value["dept"], value["amount"] status, cates, period, ranges, remark = value["status"], value["cates"], value["period"], value[ "ranges"], \ value["remark"] person_info = value["person_info"] goods_info = value["goods_info"] 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, 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, 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 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, value in info.iteritems(): equityNo, pledgor, pledBLicNo = value["equityNo"], value[ "pledgor"], value["pledBLicNo"] impAm, impOrg, impOrgBLicNo = value["impAm"], value[ "impOrg"], value["impOrgBLicNo"] equPleDate, publicDate, type = value["equPleDate"], value[ "publicDate"], value["type"] 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: 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)) update_flag += rows_count connect.commit() except Exception, e: cursor.close() connect.close() remark = 100000001 logging.error("stock error: %s" % e)
def main(gs_py_id,gs_basic_id,url): Log().found_log(gs_py_id,gs_basic_id) insert,error,total = 0,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) object = Report() flag, href_list, cookies = object.get_year_href(url) cookies = requests.utils.dict_from_cookiejar(cookies) if flag == 1: total, insert, error = object.get_all_report_info(href_list,cursor,connect,gs_basic_id,gs_py_id,cookies) if total == 0: flag = -1 except Exception,e: # print e flag = 100000005 logging.info("report error:%s"%e)
def main(code, ccode): printinfo = {} try: info, flag = get_list(code, ccode) if flag == 1: 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) info_list = get_detail(info) if info_list > 0: flag, href = update_to_db(info_list[0], cursor, connect, gs_basic_id) else: pass else: pass except Exception, e: # print e flag = 100000005 logging.error("unknow error:%s" % e)
def main(code,ccode): info = { "url": '', "flag": '', } challenge, validate, cookies = loop_break_password() if cookies == None: flag = 100000001 info["flag"] = flag elif challenge == None or validate == None: flag = 100000002 info["flag"] = flag else: url, company, history_name, flag = last_request(challenge, validate, code, ccode, cookies) if url == None: info["flag"] = flag elif flag == 1: info["url"] = url info["flag"] = flag 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) updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) if history_name!=None: select_string = select_basic % gs_basic_id count = cursor.execute(select_string) if count ==0: cursor.execute(insert_history,(gs_basic_id,history_name,updated_time)) connect.commit() elif int(count)==1: gs_basic_exp_id = cursor.fetchall()[0][0] cursor.execute(update_basic,(gs_basic_exp_id,gs_basic_id,history_name,updated_time,gs_basic_exp_id)) connect.commit() cursor.execute(update_py,(gs_py_id,gs_basic_id,updated_time,gs_py_id)) connect.commit() except Exception,e: logging.error('get url error %s' % e)
def update_to_db(self, gs_basic_id, info): update_flag, insert_flag = 0, 0 mort_flag = 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(): 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] goods_info = info[key][9] person_info = info[key][10] 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, 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, updated_time, gs_mort_id)) update_flag += flag connect.commit() self.update_person(gs_mort_id, gs_basic_id, cursor, connect, person_info) self.update_goods(gs_mort_id, gs_basic_id, cursor, connect, goods_info) except Exception, e: logging.info('mort error :%s' % e) mort_flag = 100000006
def get_info(): Log().found_log(user_id, unique_id) success, error, insert = 0, 0, 0 total = 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) info, flag = get_list(keyword) if flag == 1: datalist, total, success, error = get_detail(info) for key in datalist.keys(): information = datalist[key] tempinsert = update_to_search(information, keyword, user_id, unique_id, cursor, connect) if tempinsert == 1: insert += 1 except Exception, e: flag = 100000005 logging.error("unknow error:%s" % e)
def update_to_db(self, gs_basic_id, information): insert_flag, update_flag = 0, 0 flag = 0 total = len(information) logging.info('brand total:%s' % total) 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(): ia_zch, ia_flh, ia_zcgg = information[key][0], information[ key][1], information[key][2] ia_servicelist, ia_zyqqx, ia_zcdate = information[key][ 3], information[key][4], information[key][5] province, tmImage = information[key][6], information[key][7] if tmImage != '' or tmImage != '': ia_img_url = img_list[province].format(tmImage) else: ia_img_url = '' select_string = select_brand % ia_zch # print select_string 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): update_flag, insert_flag = 0, 0 mort_flag = 0 recordstotal = len(info) logging.info("mort total:%s" % recordstotal) 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) try: for key in info.keys(): code, dates, dept, person_name = info[key][0], info[key][ 1], info[key][2], info[key][3] number, cates, amount, ranges, period = info[key][4], info[key][5], info[key][6], info[key][7], \ info[key][8] 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, cates, period, ranges, 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, cates, period, ranges, updated_time, gs_mort_id)) update_flag += flag connect.commit() except Exception, e: logging.info('mort error :%s' % e) mort_flag = 100000006
def main(): Log().found_log(gs_py_id,gs_basic_id) 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) printinfo = { "url":0, 'flag':0 } second_url,flag,entName = get_index(code) if flag ==100000003: second_url,flag,entName = get_index(ccode) if flag == 100000003: select_string = select_name % gs_basic_id cursor.execute(select_string) name = cursor.fetchall()[0][0] second_url, flag, entName = get_index(name) if name != entName: second_url = 0 flag = 100000002 except Exception,e: logging.info("get list error:%s"%e)
def update_to_db(self, gs_basic_id, information): insert_flag, update_flag = 0, 0 flag = 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 information.keys(): ia_zch, ia_flh, ia_zcgg = information[key][0], information[ key][1], information[key][2] ia_servicelist, ia_zyqqx, ia_zcdate = information[key][ 3], information[key][4], information[key][5] nodeNum, tmImage = information[key][6], information[key][7] if tmImage != '' or tmImage != None: ia_img_url = 'http://www.gsxt.gov.cn' + '/doc/{0}/tmfiles/{1}'.format( nodeNum, str(tmImage)) else: ia_img_url = None 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, 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, value in information.iteritems(): types, result = value["types"], value["result"] check_date, gov_dept = value["check_date"], value["gov_dept"] count = cursor.execute(select_check, (gs_basic_id, check_date, types)) if count == 0: rows_count = cursor.execute(check_string, (gs_basic_id, types, result, check_date, gov_dept)) 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 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, value in info.iteritems(): content_before, content_after = value["content_before"], value[ "content_after"] change_date, item = value["change_date"], value["item"] 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, info, gs_basic_id): name, ccode, status, types = info["name"], info["code"], info[ "status"], info["types"] legal_person, runner, investor, responser = info["legal_person"], info[ "runner"], info["investor"], info["runner"] reg_date, appr_date, reg_amount, start_date = info["reg_date"], info[ "appr_date"], info["reg_amount"], info["start_date"] end_date, reg_zone, reg_address, scope = info["end_date"], info[ "reg_zone"], info["reg_address"], info["scope"] jj_type = info["jj_type"] 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) flag = 0 try: if ccode != '': # 这里时间更新为一个月前,是因为,是过更新为当天,普通用户就无法使用更新功能了 updated_time = deal_html_code.get_before_date() row_count = cursor.execute( update_string, (gs_basic_id, name, ccode, status, types, jj_type, legal_person, responser, investor, runner, reg_date, appr_date, reg_amount, start_date, end_date, reg_zone, reg_address, scope, updated_time, gs_basic_id)) logging.info('update basic :%s' % row_count) connect.commit() else: updated_time = deal_html_code.get_before_date() row_count = cursor.execute( update_string1, (gs_basic_id, name, status, types, jj_type, legal_person, responser, investor, runner, reg_date, appr_date, reg_amount, start_date, end_date, reg_zone, reg_address, scope, updated_time, gs_basic_id)) logging.info('update basic :%s' % row_count) connect.commit() except Exception, e: print "basic error:%s" % e logging.error("basic error:%s" % e) flag = 100000006
def main(): Log().found_log(gs_py_id, 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) try: select_string = select_report % gs_basic_id count = cursor.execute(select_string) if count == 1: for data1, data2, data3 in cursor.fetchall(): if data1 == u'无' or data1 == '': data1 = None if data2 == u'无' or data2 == '': data2 = None if data3 == u'无' or data3 == '': data3 = None tel = data1 address = data2 email = data3 updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) cursor.execute( update_address, (gs_basic_id, tel, address, email, updated_time, gs_basic_id)) connect.commit() info, flag, url_list = get_url_list(url) if flag < 100000001: flag = update_basic(info, connect, cursor, gs_basic_id) updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) cursor.execute(update_py, (gs_py_id, flag, updated_time, gs_py_id)) connect.commit() except Exception, e: flag = 100000005 logging.error('basic error %s' % e)