def isa_border_ins(arr, meet_seq, rcp_no, hold_seq): # 가결여부 act_rst = arr[4] """보류 if '가결' in act_rst or '찬성' in act_rst or '승인' in act_rst: act_rst = 'Y' elif '부결' in act_rst or '반대' in act_rst or '미승인' in act_rst: act_rst = 'N' elif '보고' in act_rst: act_rst = 'B' elif '심의완료' in act_rst: act_rst = 'C' else: act_rst = 'E' """ # 위원회명, 코드 comt_nm = arr[0].replace("\n", "").replace(" ", "") """보류 if comt_nm == '사외이사후보추천위원회': comt_nm = '사추위' comt_cd_sel = "select cd_val from ssg00011 where com_cd_tp_cd = 'comt_cd' and cd_nm = '{0}'".format(comt_nm) """ in_qry = """insert into proxy015(meet_seq, rcp_no, comt_cd, comt_nm, comt_member, comt_dt, comt_hold_seq, comt_cont, comt_rstyn, create_dt, modify_dt) values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}') """.format(meet_seq, rcp_no, comt_nm, comt_nm, arr[1], make_ymd(arr[2]), hold_seq, arr[3], act_rst, create_dt, create_dt) return in_qry
def act_cont_ins(c_arr, meet_seq, rcp_no, agno, is_gagyul): # 회차 act_seq = c_arr[0] """보류 if '임시' in act_seq: act_seq = '0' else: act_seq = get_num(get_round(act_seq)) """ # 가결여부 if is_gagyul == 1: act_rst = c_arr[3] else: act_rst = '' """보류 if '가결' in act_rst or '찬성' in act_rst or '승인' in act_rst: act_rst = 'Y' elif '부결' in act_rst or '반대' in act_rst or '미승인' in act_rst: act_rst = 'N' elif '보고' in act_rst: act_rst = 'B' else: act_rst = 'E' """ in_qry = """insert into proxy012(meet_seq, rcp_no, act_seq, act_ymd, act_agno, act_content, act_rst, create_dt, modify_dt) values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}') """.format(meet_seq, rcp_no, act_seq, make_ymd(c_arr[1]), agno, c_arr[2], act_rst, create_dt, create_dt) return in_qry
def deri_ins(meet_seq, rcp_no, pre_rcp_no, jm_code, meet_ymd, notice_gb, meet_ymdstr, meet_area): jm_nm = "select jm_nm from gcoga000 where jm_code = '{0}'".format(jm_code) in_qry = """insert into proxy_deri001(meet_seq, rcp_no, rcp_no_pre, jm_code, jm_name, meet_ymd, meet_gb, meet_ymdstr, meet_area, data_yn) values('{0}', '{1}', '{2}', '{3}', ({4}), '{5}', '{6}', '{7}', '{8}', 'N') """.format(meet_seq, rcp_no, pre_rcp_no, jm_code, jm_nm, make_ymd(meet_ymd), notice_gb, meet_ymdstr, meet_area.replace("'", "")) return in_qry
def act_isa_ins(isa_nm, c_arr, meet_seq, rcp_no, agno, seq, is_gagyul): # 회차 act_seq = c_arr[0] """보류 if '임시' in act_seq: act_seq = '0' else: act_seq = get_num(get_round(act_seq)) """ # 찬반여부 yn_num = 4 if is_gagyul == 0: yn_num = 3 appr_yn = c_arr[seq + yn_num] attn_yn = c_arr[seq + yn_num] """ 보류 if '찬성' in appr_yn or '가결' in appr_yn: appr_yn = 'Y' elif '반대' in appr_yn or '부결' in appr_yn: appr_yn = 'N' elif '보류' in appr_yn: appr_yn = 'B' elif '제한' in appr_yn: appr_yn = 'J' elif '해당' in appr_yn or '없음' in appr_yn or '퇴임' in appr_yn or '선임' in appr_yn or '만료' in appr_yn: appr_yn = '' else: appr_yn = 'E' # 참석여부 if '참석' in attn_yn or '찬성' in attn_yn or '반대' in attn_yn or '가결' in attn_yn or '부결' in attn_yn: attn_yn = 'Y' elif '불참' in attn_yn or '미참' in attn_yn or '-' == attn_yn: attn_yn = 'N' elif '해당' in attn_yn or '없음' in attn_yn or '퇴임' in attn_yn or '선임' in attn_yn or '만료' in attn_yn: attn_yn = '' else: attn_yn = 'E' """ # 성명 / 이물코드 name = get_nm(isa_nm.replace(" ", "")) jm_code = meet_seq[:6] pe_code = get_pecode(jm_code, name) in_qry = """insert into proxy013(meet_seq, rcp_no, act_seq, act_ymd, act_agno, pe_seq, pe_code, isa_nm, appr_yn, attn_yn, create_dt, modify_dt) values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}') """.format(meet_seq, rcp_no, act_seq, make_ymd(c_arr[1]), agno, jm_code + str(seq + 1).zfill(4), pe_code, name, appr_yn, attn_yn, create_dt, create_dt) return in_qry
def resolution_mst_ins(meet_seq, meet_tb, jm_code, rcp_no, first_rcpno): # 주총 결의_데이터 변환 meet_tb[0] = make_ymd(meet_tb[0]).replace("'", "") # 주총일자 YYYYMMDD meet_tb[1] = make_time(meet_tb[1]).replace("'", "") # hhmm meet_tb[2] = meet_tb[2].replace("'", "") # 주주총회 장소 meet_tb[3] = str(meet_tb[3]).replace("'", "") # 의안내용 쿼테이션 제거 meet_tb[4] = make_ymd(meet_tb[4]).replace("'", "") # 이사회 결의일 YYYYMMDD meet_tb[5] = get_antCnt(meet_tb[5]).replace("'", "") # 참석수 meet_tb[6] = get_antCnt(meet_tb[6]).replace("'", "") # 불참석수 meet_tb[7] = get_atnYn(meet_tb[7]).replace("'", "") # 감사 참석여부 meet_tb[8] = get_regYn(meet_tb[8]).replace("'", "") # 1:정기, 2:임시 in_qry = """ insert into proxy001(meet_seq, rcp_no, jm_code, meet_gb, first_rcpno, meet_ymd, meet_time, meet_location, meet_content, meet_result_dt, isa_atn, isa_abs, gamsa_atn, create_dt, modify_dt) values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}') """.format(meet_seq, rcp_no, jm_code, meet_tb[8], first_rcpno, meet_tb[0], meet_tb[1], meet_tb[2], meet_tb[3], meet_tb[4], meet_tb[5], meet_tb[6], meet_tb[7], create_dt, create_dt) return in_qry
def get_resolution(jm_code, rcp_no, rcp_gb, cursor): try: # driver 세팅(결의, 공고) driver = get_driver( 'C:\\Users\\admin\\PycharmProjects\\webCrawl\\chromedriver.exe', 'http://dart.fss.or.kr/dsaf001/main.do?rcpNo={0}'.format(rcp_no)) driver.implicitly_wait(10) # 주총 공고의 rcpno 히스토리 rcpno_list = get_rcpno_list(driver) # 최초 문서의 공고년도 first_rcp_no = rcpno_list[0] first_rcp_yy = first_rcp_no[:4] # 주총결의 데이터 세팅 driver.switch_to.frame(driver.find_element_by_tag_name("iframe")) # 상장 구분 if 'Y' in rcp_gb: tb_mst = driver.find_elements_by_xpath( '//*[@id="XFormD52_Form0_Table0"]/tbody/tr') else: tb_mst = driver.find_elements_by_xpath( '//*[@id="XFormD2_Form0_Table0"]/tbody/tr') # 주총 결의 meet_tb = [0 for x in range(9)] if 'Y' in rcp_gb: meet_tb[0] = tb_mst[1].find_elements_by_tag_name( 'td')[1].text # 일자 meet_tb[1] = tb_mst[1].find_elements_by_tag_name( 'td')[2].text # 시간 meet_tb[8] = tb_mst[0].find_elements_by_tag_name( 'td')[1].text # 주총구분 else: meet_tb[0] = tb_mst[0].find_elements_by_tag_name( 'td')[2].text # 일자 meet_tb[1] = tb_mst[1].find_elements_by_tag_name( 'td')[1].text # 시간 meet_tb[8] = tb_mst[8].find_elements_by_tag_name( 'td')[1].text # 주총구분 meet_tb[2] = tb_mst[2].find_elements_by_tag_name('td')[1].text # 장소 meet_tb[3] = tb_mst[3].find_elements_by_tag_name('td')[1].text # 의안내용 meet_tb[4] = tb_mst[4].find_elements_by_tag_name( 'td')[1].text # 이사회결의일 meet_tb[5] = tb_mst[5].find_elements_by_tag_name( 'td')[2].text # 사외이사_참 meet_tb[6] = tb_mst[6].find_elements_by_tag_name( 'td')[1].text # 사외이사_불참 meet_tb[7] = tb_mst[7].find_elements_by_tag_name( 'td')[1].text # 감사참석여부 # 사외이사 선임 및 사업목적 테이블 유무 확인 """isa_1, isa_2, isa_3, isa_4, tb_biz = False, False, False, False, False spans = driver.find_elements_by_tag_name('span') for span in spans: title = span.text title = get_hangul(title) if title == '이사선임세부내역': isa_1 = True elif title == '사외이사선임세부내역': isa_2 = True elif title == '감사위원선임세부내역': isa_3 = True elif title == '감사선임세부내역': isa_4 = True elif title == '사업목적변경세부내역': tb_biz = True """ # 이사선임 & 사업목적 isa_arr = [] biz_arr = [] if 'Y' in rcp_gb: # 이사선임 isa_1 = driver.find_elements_by_xpath( '//*[@id="LIB_L9019"]') # 이사선임 div 유무 isa_2 = driver.find_elements_by_xpath( '//*[@id="LIB_L9018"]') # 사외이사선임 div 유무 isa_3 = driver.find_elements_by_xpath( '//*[@id="LIB_L9016"]') # 감사위원선임 div 유무 isa_4 = driver.find_elements_by_xpath( '//*[@id="LIB_L9015"]') # 감사선임 div 유무 if isa_1: isa_arr.extend(get_isa(driver, 'LIB_L9019')) if isa_2: isa_arr.extend(get_isa(driver, 'LIB_L9018')) if isa_3: isa_arr.extend(get_isa(driver, 'LIB_L9016')) if isa_4: isa_arr.extend(get_isa(driver, 'LIB_L9015')) # 사업목적 tb_biz = driver.find_elements_by_xpath( '//*[@id="LIB_L9017"]') # 사업목적 div 유무 if tb_biz: biz_arr.extend(get_biz(driver, 'LIB_L9017')) elif 'K' in rcp_gb: # 이사선임 isa_1 = driver.find_elements_by_xpath( '//*[@id="LIB_L7021"]') # 이사선임 div 유무 isa_2 = driver.find_elements_by_xpath( '//*[@id="LIB_L7020"]') # 사외이사선임 div 유무 isa_3 = driver.find_elements_by_xpath( '//*[@id="LIB_L7018"]') # 감사위원선임 div 유무 isa_4 = driver.find_elements_by_xpath( '//*[@id="LIB_L7017"]') # 감사선임 div 유무 if isa_1: isa_arr.extend(get_isa(driver, 'LIB_L7021')) if isa_2: isa_arr.extend(get_isa(driver, 'LIB_L7020')) if isa_3: isa_arr.extend(get_isa(driver, 'LIB_L7018')) if isa_4: isa_arr.extend(get_isa(driver, 'LIB_L7017')) # 사업목적 tb_biz = driver.find_elements_by_xpath( '//*[@id="LIB_L7019"]') # 사업목적 div 유무 if tb_biz: biz_arr.extend(get_biz(driver, 'LIB_L7019')) else: # 이사선임 isa_1 = driver.find_elements_by_xpath( '//*[@id="LIB_L3025"]') # 이사선임 div 유무 isa_2 = driver.find_elements_by_xpath( '//*[@id="LIB_L3024"]') # 사외이사선임 div 유무 isa_3 = driver.find_elements_by_xpath( '//*[@id="LIB_L3022"]') # 감사위원선임 div 유무 isa_4 = driver.find_elements_by_xpath( '//*[@id="LIB_L3021"]') # 감사선임 div 유무 if isa_1: isa_arr.extend(get_isa(driver, 'LIB_L3025')) if isa_2: isa_arr.extend(get_isa(driver, 'LIB_L3024')) if isa_3: isa_arr.extend(get_isa(driver, 'LIB_L3022')) if isa_4: isa_arr.extend(get_isa(driver, 'LIB_L3021')) # 사업목적 tb_biz = driver.find_elements_by_xpath( '//*[@id="LIB_L3023"]') # 사업목적 div 유무 if tb_biz: biz_arr.extend(get_biz(driver, 'LIB_L3023')) # --------------------------------------------------------------------------------- # # DB 삽입 # 중복체크 dup_select = """select * from proxy001 where rcp_no = '{0}'""".format( rcp_no) cursor.execute(dup_select) dup_cnt = cursor.rowcount if dup_cnt > 0: return 0 # 회차 max 값 max_select = """select * from proxy001 where left(first_rcpno, 4) = '{0}' and jm_code = '{1}' group by meet_seq """.format(first_rcp_yy, jm_code) cursor.execute(max_select) max_seq = cursor.rowcount # meet_seq 생성 seq_select = """select meet_seq from proxy001 where first_rcpno = '{0}' """.format(first_rcp_no) cursor.execute(seq_select) seq = cursor.fetchone() if cursor.rowcount < 1: seq = str(max_seq + 1).zfill(2) else: seq = "".join(seq) seq = seq[-2:] yyyy = make_ymd(meet_tb[0][:4]) if yyyy is not None and yyyy != '': yyyy = yyyy[:4] else: yyyy = time.strftime('%Y') meet_seq = jm_code + yyyy + seq # 결의 mst 삽입 in_qry = resolution_mst_ins(meet_seq, meet_tb, jm_code, rcp_no, rcpno_list[0]) cursor.execute(in_qry) #print(in_qry) # 이사선임 삽입 if isa_arr: #print(isa_arr) for i in range(0, len(isa_arr)): ins_isa_info = isa_info_ins(meet_seq, isa_arr[i], rcp_no, i) cursor.execute(ins_isa_info) #print(str(i), '번째 이사 쿼리 : ', ins_isa_info) if chk_no_data(isa_arr[i][4]): ins_isa_car = isa_car_ins(meet_seq, isa_arr[i], rcp_no, i) # 이사선임_경력 cursor.execute(ins_isa_car) #print(str(i), '번째 이사 경력 쿼리 : ', ins_isa_car) if chk_no_data(isa_arr[i][5]): ins_isa_dup = isa_dup_ins(meet_seq, isa_arr[i], rcp_no, i) # 이사선임_겸직 cursor.execute(ins_isa_dup) #print(str(i), '번째 이사 겸직 쿼리 : ', ins_isa_dup) # 사업목적 변경 삽입 if biz_arr: for i in range(0, len(biz_arr)): #print(biz_arr[i]) ins_biz = biz_ins(meet_seq, biz_arr[i], rcp_no) cursor.execute(ins_biz) #print("사업목적 변경 쿼리 : ", ins_biz) except Exception as e: error_logger.error( 'Resolution crawling fail. : [{0}] [{1}] {2}'.format( jm_code, rcp_no, e)) finally: close_driver(driver)
def resolution_main(jm_code, rcp_no, rcp_yn, rcp_gb): # driver 세팅(결의, 공고) driver = get_driver( 'C:\\Users\\admin\\PycharmProjects\\webCrawl\\chromedriver.exe', 'http://dart.fss.or.kr/dsaf001/main.do?rcpNo={0}'.format(rcp_no)) # 주총결의 데이터 세팅 driver.switch_to.frame(driver.find_element_by_tag_name("iframe")) # 상장 구분 if '유가' in rcp_gb: tb_mst = driver.find_elements_by_xpath( '//*[@id="XFormD52_Form0_Table0"]/tbody/tr') else: tb_mst = driver.find_elements_by_xpath( '//*[@id="XFormD2_Form0_Table0"]/tbody/tr') # 주총 결의 meet_tb = [0 for x in range(9)] if '유가' in rcp_gb: meet_tb[0] = tb_mst[1].find_elements_by_tag_name('td')[1].text # 일자 meet_tb[1] = tb_mst[1].find_elements_by_tag_name('td')[2].text # 시간 meet_tb[8] = tb_mst[0].find_elements_by_tag_name('td')[1].text # 주총구분 else: meet_tb[0] = tb_mst[0].find_elements_by_tag_name('td')[2].text # 일자 meet_tb[1] = tb_mst[1].find_elements_by_tag_name('td')[1].text # 시간 meet_tb[8] = tb_mst[8].find_elements_by_tag_name('td')[1].text # 주총구분 meet_tb[2] = tb_mst[2].find_elements_by_tag_name('td')[1].text # 장소 meet_tb[3] = tb_mst[3].find_elements_by_tag_name('td')[1].text # 의안내용 meet_tb[4] = tb_mst[4].find_elements_by_tag_name('td')[1].text # 이사회결의일 meet_tb[5] = tb_mst[5].find_elements_by_tag_name('td')[2].text # 사외이사_참 meet_tb[6] = tb_mst[6].find_elements_by_tag_name('td')[1].text # 사외이사_불참 meet_tb[7] = tb_mst[7].find_elements_by_tag_name('td')[1].text # 감사참석여부 # 이사선임 & 사업목적 isa_arr = [] biz_arr = [] if '유가' in rcp_gb: # 이사선임 isa_1 = driver.find_elements_by_xpath( '//*[@id="LIB_L9019"]') # 이사선임 div 유무 isa_2 = driver.find_elements_by_xpath( '//*[@id="LIB_L9018"]') # 사외이사선임 div 유무 isa_3 = driver.find_elements_by_xpath( '//*[@id="LIB_L9016"]') # 감사위원선임 div 유무 isa_4 = driver.find_elements_by_xpath( '//*[@id="LIB_L9015"]') # 감사선임 div 유무 if isa_1 != '' and isa_1: isa_arr.extend(get_isa(driver, 'LIB_L9019')) if isa_2 != '' and isa_2: isa_arr.extend(get_isa(driver, 'LIB_L9018')) if isa_3 != '' and isa_3: isa_arr.extend(get_isa(driver, 'LIB_L9016')) if isa_4 != '' and isa_4: isa_arr.extend(get_isa(driver, 'LIB_L9015')) # 사업목적 tb_biz = driver.find_elements_by_xpath( '//*[@id="LIB_L9017"]') # 사업목적 div 유무 if tb_biz != '' and tb_biz: biz_arr.extend(get_biz(driver, 'LIB_L9017')) elif '코스닥' in rcp_gb: # 이사선임 isa_1 = driver.find_elements_by_xpath( '//*[@id="LIB_L7021"]') # 이사선임 div 유무 isa_2 = driver.find_elements_by_xpath( '//*[@id="LIB_L7020"]') # 사외이사선임 div 유무 isa_3 = driver.find_elements_by_xpath( '//*[@id="LIB_L7018"]') # 감사위원선임 div 유무 isa_4 = driver.find_elements_by_xpath( '//*[@id="LIB_L7017"]') # 감사선임 div 유무 if isa_1 != '' and isa_1: isa_arr.extend(get_isa(driver, 'LIB_L7021')) if isa_2 != '' and isa_2: isa_arr.extend(get_isa(driver, 'LIB_L7020')) if isa_3 != '' and isa_3: isa_arr.extend(get_isa(driver, 'LIB_L7018')) if isa_4 != '' and isa_4: isa_arr.extend(get_isa(driver, 'LIB_L7017')) # 사업목적 tb_biz = driver.find_elements_by_xpath( '//*[@id="LIB_L7019"]') # 사업목적 div 유무 if tb_biz != '' and tb_biz: biz_arr.extend(get_biz(driver, 'LIB_L7019')) else: # 이사선임 isa_1 = driver.find_elements_by_xpath( '//*[@id="LIB_L3025"]') # 이사선임 div 유무 isa_2 = driver.find_elements_by_xpath( '//*[@id="LIB_L3024"]') # 사외이사선임 div 유무 isa_3 = driver.find_elements_by_xpath( '//*[@id="LIB_L3022"]') # 감사위원선임 div 유무 isa_4 = driver.find_elements_by_xpath( '//*[@id="LIB_L3021"]') # 감사선임 div 유무 if isa_1 != '' and isa_1: isa_arr.extend(get_isa(driver, 'LIB_L3025')) if isa_2 != '' and isa_2: isa_arr.extend(get_isa(driver, 'LIB_L3024')) if isa_3 != '' and isa_3: isa_arr.extend(get_isa(driver, 'LIB_L3022')) if isa_4 != '' and isa_4: isa_arr.extend(get_isa(driver, 'LIB_L3021')) # 사업목적 tb_biz = driver.find_elements_by_xpath( '//*[@id="LIB_L3023"]') # 사업목적 div 유무 if tb_biz != '' and tb_biz: biz_arr.extend(get_biz(driver, 'LIB_L3023')) # DB 삽입 try: conn = get_dbcon('esg') cursor = conn.cursor() try: # 조회용 주총 값 ymd = make_ymd(meet_tb[0]) gb = get_regYn(meet_tb[8]) seq_select = """select * from proxy001 where meet_ymd = '{0}' and jm_code = '{1}' and meet_gb = '{2}' """.format(ymd, jm_code, gb) cursor.execute(seq_select) rows = cursor.rowcount # 기재정정이 아닐 경우 중복체크 if rcp_yn == '' and rows > 0: print('중복 데이터가 있습니다.') sys.exit(0) # report_ver 키값 생성(개정일 + seq) report_ver = rcp_no[:8] + str(rows + 1).zfill(2) # 결의 mst 삽입 in_qry = resolution_mst_ins(meet_tb, jm_code, report_ver, rcp_no) cursor.execute(in_qry) print(in_qry) # 이사선임 삽입 if isa_arr: ins_isa, dup_isa = isa_mst_ins(isa_arr, meet_tb[0], jm_code, gb, report_ver) # 이사선임 for i in range(0, len(ins_isa)): # 이사 중복 체크 cursor.execute(dup_isa[i]) dup_cnt = cursor.rowcount if dup_cnt > 0: print('중복된 이사가 있습니다.') continue cursor.execute(ins_isa[i]) print(str(i) + " : " + ins_isa[i]) if chk_no_data(isa_arr[i][4]): ins_isa_car = isa_car_ins(isa_arr[i], meet_tb[0], jm_code, gb, report_ver, i) # 이사선임_경력 cursor.execute(ins_isa_car) print(str(i) + " : " + ins_isa_car) if chk_no_data(isa_arr[i][5]): ins_isa_dup = isa_dup_ins(isa_arr[i], meet_tb[0], jm_code, gb, report_ver, i) # 이사선임_겸직 cursor.execute(ins_isa_dup) print(str(i) + " : " + ins_isa_dup) # 사업목적 변경 삽입 if biz_arr: for i in range(0, len(biz_arr)): ins_biz = biz_ins(biz_arr, meet_tb[0], jm_code, gb, report_ver) cursor.execute(ins_biz[i]) print(str(i) + " : " + str(ins_biz[i])) except: f = open("C:\\Users\\rmffo\\PycharmProjects\\log\\error_log.txt", 'a') f.write(jm_code + '\n') f.close() cursor.close() finally: close_dbcon(conn) # driver close close_driver(driver)
def get_notice(jm_code, rcp_no, cursor): try: # driver 세팅 driver = get_driver( 'C:\\Users\\admin\\PycharmProjects\\webCrawl\\chromedriver.exe', 'http://dart.fss.or.kr/dsaf001/main.do?rcpNo={0}'.format(rcp_no)) # 주총 공고의 rcpno 히스토리 rcpno_list = get_rcpno_list(driver) # 최초 문서의 공고년도 first_rcp_no = rcpno_list[0] first_rcp_yy = first_rcp_no[:4] # 이전 rcp_no pre_rcp_no = '' for i in range(0, len(rcpno_list)): if rcp_no == rcpno_list[i] and i > 0: pre_rcp_no = rcpno_list[i - 1] break print(rcpno_list, pre_rcp_no) # ------------------------- 주총공고 ------------------------- try: notice_gb, notice_tb, notice_ref, notice_etc = get_notice_data( rcp_no, driver) # 중복체크 dup_select = """select * from proxy011 where rcp_no = '{0}'""".format( rcp_no) cursor.execute(dup_select) dup_cnt = cursor.rowcount if dup_cnt > 0: return 0 res_rcpno = '' # 결의문 rcpno 가져오기 if len(notice_tb[0]) == 8: res_select = """select first_rcpno from proxy001 where jm_code = '{0}' and meet_ymd = '{1}' and meet_gb = '{2}' and meet_time = '{3}' """.format(jm_code, notice_tb[0], notice_gb, notice_tb[1]) cursor.execute(res_select) if cursor.rowcount > 0: res_rcpno = cursor.fetchone()[0] # 회차 max 값 max_select = """select * from proxy011 where left(first_rcpno, 4) = '{0}' and jm_code = '{1}' group by meet_seq """.format(first_rcp_yy, jm_code) cursor.execute(max_select) max_seq = cursor.rowcount # meet_seq 생성 seq_select = """select meet_seq from proxy011 where first_rcpno = '{0}' """.format(first_rcp_no) cursor.execute(seq_select) seq = cursor.fetchone() if cursor.rowcount < 1: seq = str(max_seq + 1).zfill(2) else: seq = "".join(seq) seq = seq[-2:] yyyy = make_ymd(notice_tb[0]) if yyyy is not None and yyyy != '': yyyy = yyyy[:4] else: yyyy = time.strftime('%Y') meet_seq = jm_code + yyyy + seq notice_qry = notice_mst_ins(meet_seq, rcp_no, jm_code, notice_gb, rcpno_list[0], notice_tb, notice_ref, res_rcpno) cursor.execute(notice_qry) # crawling to deri ymdstr = get_full_ymdstr(notice_tb[0], notice_tb[1]) deri_qry = deri_ins(meet_seq, rcp_no, pre_rcp_no, jm_code, notice_tb[0], notice_gb, ymdstr, notice_tb[2]) cursor.execute(deri_qry) driver.switch_to_default_content() info_logger.info('[0] Key creation success.') except Exception as e: error_logger.error('[0] Key creation fail. [{0}] : {1}'.format( rcp_no, e)) # ------------------------- 이사 및 위원회 활동내역 ------------------------- get_isa_act(driver, meet_seq, rcp_no, cursor) driver.switch_to_default_content() # ------------------------- 사외이사보수 ------------------------- get_isa_bosu(driver, meet_seq, rcp_no, cursor) driver.switch_to_default_content() # ------------------------- 단일 거래규모 일정규모 이상 거래 ------------------------- get_transaction_single(driver, meet_seq, rcp_no, cursor) driver.switch_to_default_content() # ------------------------- 거래총액 일정규모 이상 거래 ------------------------- get_transaction_total(driver, meet_seq, rcp_no, cursor) driver.switch_to_default_content() # ------------------------- 재무제표 ------------------------- get_financial_table(driver, meet_seq, rcp_no, cursor) # ------------------------- 정관의 변경 ------------------------- get_change_article(driver, meet_seq, rcp_no, cursor) # ------------------------- 이사선임 ------------------------- get_elect_isa(driver, meet_seq, rcp_no, cursor) # ------------------------- 이사보수한도 ------------------------- get_limit_bosu(driver, meet_seq, rcp_no, cursor) # ------------------------- 주식매수선택권 ------------------------- get_stockoption(driver, meet_seq, rcp_no, cursor) except Exception as e: error_logger.error('[Notice] crawling fail. [{0}] : {1}'.format( rcp_no, e)) finally: close_driver(driver)