def parse(self, parser, response): tr = parser.find('tr', {'class': 'bot'}) tds = tr.find_all('td') address = tds[2].get_text(strip=True) parcel = Parcel() parcel.address = address self.parcel = parcel tables = parser.find_all('table', {'class': 'table_02'}) trs = tables[1].find_all('tr') for tr in trs: tds = tr.find_all('td') if len(tds) > 0: time = '%s %s' % (getattr(tds[0], 'string', ''), getattr(tds[1], 'string', '')) location = getattr(tds[2].a, 'string', '') status = getattr(tds[3].p, 'string', '') track = Track() track.time = time track.location = location track.status = status self.add_track(track)
def parse(self, parser, response): basic_table = parser.find('table', {'class': 'view'}) ths = basic_table.find_all('th') tds = basic_table.find_all('td') sender_name = getattr(tds[1], 'string', '') memo = getattr(tds[2], 'string', '') receiver_name = getattr(tds[3], 'string', '') address = getattr(tds[5], 'string', '') parcel = Parcel() parcel.sender = sender_name parcel.receiver = receiver_name parcel.address = address parcel.note = memo self.parcel = parcel track_table = parser.find('table', {'class': 'list'}) cols = track_table.find('thead').find('tr').find_all('th') rows = track_table.find('tbody').find_all('tr') for row in rows: tds = row.find_all('td') time = getattr(tds[0], 'string', '') status = getattr(tds[1], 'string', '') location = getattr(tds[2], 'string', '') phone = getattr(tds[3], 'string', '') track = Track() track.status = status track.location = location track.phone1 = phone self.add_track(track)
def parse(self, parser): basic_table = parser.find_all('table', {'class': 'table_col'})[0] tds = basic_table.find_all('td') sender = tds[0] receiver = tds[1] note = tds[2] parcel = Parcel() parcel.sender = sender parcel.receiver = receiver parcel.note = note self.parcel = parcel track_table = parser.find_all('table', {'class': 'table_col'})[1] trs = track_table.find_all('tr') for tr in trs: tds = tr.find_all('td') if len(tds) > 0: time = '%s %s' % (getattr(tds[0], 'string', ''), getattr(tds[1], 'string', '')) location = getattr(tds[2], 'string', '') status = getattr(tds[3], 'string', '') track = Track() track.time = time track.location = location track.status = status self.add_track(track)
def parse(self, parser): table = parser.find('table', {'class': 'table_col ma_b_5'}) cols = table.find('thead').find('tr').find_all('th') rows = table.find('tbody').find_all('tr') self.parcel = Parcel() for row in rows: tds = row.find_all('td') time = getattr(tds[0].find('br'), 'next_sibling', '') or \ getattr(tds[1].find('br'), 'next_sibling', '') status = getattr(tds[2], 'string', '') track = Track() track.status = status track.time = time self.add_track(track)
def parse(self, parser, response): div = parser.find('div', {'class': 'sub_emspop_table'}) table = div.find('table') cols = table.find('thead').find('tr').find_all('th') rows = table.find('tbody').find_all('tr') for row in rows: tds = row.find_all('td') time = getattr(tds[0], 'string', '') location = getattr(tds[2], 'string', '') status = getattr(tds[1], 'string', '') track = Track() track.location = location track.status = status track.time = time self.add_track(track)
def parse(self, parser): tables = parser.find_all('table', {'class': 'order_tb_result'}) tds = tables[0].find_all('td') sender = getattr(tds[9], 'string', '') receiver = getattr(tds[11], 'string', '') address = getattr(tds[19], 'string', '') tr = tables[1].find_all('tr')[1] memo = getattr(tr.find_all('td')[3], 'string', '') + ' ' + getattr( tr.find_all('td')[4], 'string', '') parcel = Parcel() parcel.sender = sender parcel.receiver = receiver parcel.address = address parcel.note = memo self.parcel = parcel trs = tables[2].find_all('tr') for i, tr in enumerate(trs): if i != 0: tds = tr.find_all('td') time = getattr(tds[0], 'string', '') location = getattr(tds[1], 'string', '') phone = getattr(tds[2], 'string', '') status = getattr(tds[3], 'string', '') track = Track() track.time = time track.location = location track.status = status track.phone1 = phone self.add_track(track)
def parse(self, parser): tables = parser.find_all('tbody') if (len(tables) > 0): basic_info = tables[0].find_all('td', {'class': 'bb'}) tracking_info = tables[1].find_all('tr') stuff_name = getattr(basic_info[1], 'get_text', '')(strip=True) sender_name = getattr(basic_info[3], 'get_text', '')(strip=True) receiver_name = getattr(basic_info[4], 'get_text', '')(strip=True) receiver_address = getattr(basic_info[5], 'get_text', '')(strip=True) parcel = Parcel() parcel.sender = sender_name parcel.receiver = receiver_name parcel.address = receiver_address parcel.note = stuff_name self.parcel = parcel for tr in tracking_info: tds = tr.find_all('td') if len(tds) == 5: date = getattr(tds[0], 'get_text', '')(strip=True) time = getattr(tds[1], 'get_text', '')(strip=True) location = getattr(tds[2], 'get_text', '')(strip=True) status = getattr(tds[3], 'get_text', '')(strip=True) phone = getattr(tds[4], 'get_text', '')(strip=True) track = Track() track.time = '%s %s' % (date, time) track.location = location track.status = status track.phone1 = phone self.add_track(track)
def parse(self, parser): tracking_info = parser.find('tracking_info') sender_name = getattr(tracking_info.find('sender_name'), 'string', '') receiver_name = getattr(tracking_info.find('reciver_name'), 'string', '') receiver_addr = getattr(tracking_info.find('reciver_addr'), 'string', '') item_name = getattr(tracking_info.find('item_name'), 'string', '') if sender_name is not None: sender_name = re.sub('[\[CDATA\]]', '', sender_name) if receiver_name is not None: receiver_name = re.sub('[\[CDATA\]]', '', receiver_name) if receiver_addr is not None: receiver_addr = re.sub('[\[CDATA\]]', '', receiver_addr) parcel = Parcel() parcel.receiver = receiver_name parcel.sender = sender_name parcel.address = receiver_addr parcel.note = item_name self.parcel = parcel list_tracking_details = tracking_info.find_all('tracking_details') for tracking_details in list_tracking_details: trans_time = getattr(tracking_details.find('trans_time'), 'string', '') trans_kind = getattr(tracking_details.find('trans_kind'), 'string', '') trans_where = getattr(tracking_details.find('trans_where'), 'string', '') trans_telno = getattr(tracking_details.find('trans_telno'), 'string', '') track = Track() track.time = trans_time track.status = trans_kind track.location = trans_where track.phone1 = trans_telno self.add_track(track)
def parse(self, parser, response): basic_table = parser.find('table', {'class': 'i_table_01'}) trs = basic_table.find_all('tr') sender = trs[0].find_all('td')[1].get_text() note = trs[1].find_all('td')[0].get_text() receiver = trs[1].find_all('td')[1].get_text() address = trs[3].find('td').get_text() parcel = Parcel() parcel.sender = sender parcel.receiver = receiver parcel.address = address parcel.note = note self.parcel = parcel track_table = parser.find('table', {'class': 'c_table_01'}) trs = track_table.find_all('tr') for tr in trs: tds = tr.find_all('td') if len(tds) == 5: time = '%s %s' % ( tds[0].find('span').get_text(), tds[1].find('span').get_text(), ) status = tds[2].find('span').get_text() location = tds[3].find('span').get_text() phone1 = tds[4].find('span').get_text() track = Track() track.time = time track.status = status track.location = location track.phone1 = phone1 self.add_track(track)
def parse(self, parser): div = parser.find('div', {'class': 'myatable03 mts'}) basic_table = div.find('table') tds = basic_table.find_all('td') sender_name = getattr(tds[0], 'string', '') address = getattr(tds[1], 'string', '') parcel = Parcel() parcel.sender = sender_name parcel.address = address self.parcel = parcel div2 = parser.find_all('div', {'class': 'myatable03 mtxxs'})[1] track_table = div2.find('table') rows = track_table.find_all('tr') for row in rows: tds = row.find_all('td') if len(tds) > 0: time = getattr(tds[0], 'string', '') status = getattr(tds[3], 'string', '') location = getattr(tds[1], 'string', '') phone = '%s %s' % (getattr(tds[4], 'string', ''), getattr(tds[2], 'string', '')) track = Track() track.time = time track.status = status track.location = location track.phone1 = phone self.add_track(track)
def parse(self, parser, response): tables = parser.find_all('tbody') cols = parser.find('thead').find('tr').find_all('th') trs = tables[0].find_all('tr') customer_infos = [] for tr in trs: ths = tr.find_all('th') tds = tr.find_all('td') for index, th in enumerate(ths): td = tds[index].get_text(strip=True) if th != '': customer_infos.append(td) parcel = Parcel() parcel.sender = customer_infos[1] parcel.receiver = customer_infos[4] parcel.address = customer_infos[6] parcel.note = customer_infos[7] self.parcel = parcel trs = tables[1].find_all('tr') for tr in trs: tds = tr.find_all('td') location = getattr(tds[0], 'get_text', '')(strip=True) phone1 = getattr(tds[1], 'get_text', '')(strip=True) phone2 = getattr(tds[6], 'get_text', '')(strip=True) status = getattr(tds[2], 'get_text', '')(strip=True) time = getattr(tds[3], 'get_text', '')(strip=True) track = Track() track.location = location track.phone1 = phone1 track.phone2 = phone2 track.status = status track.time = time self.add_track(track)
def parse(self, parser, response): if self.auth_key is None: raise EnvironmentError('The auth_key must be set!') longitudinal_domestic_list_response = parser.find( 'longitudinaldomesticlistresponse') cmm_msg_header = longitudinal_domestic_list_response.find( 'cmmmsgheader') request_msg_id = cmm_msg_header.find('requestmsgid').string response_msg_id = cmm_msg_header.find('responsemsgid').string response_time = cmm_msg_header.find('responsetime').string success_y_n = cmm_msg_header.find('successyn').string return_code = cmm_msg_header.find('returncode').string err_msg = cmm_msg_header.find('errmsg').string # 수취인 addrse_nm = longitudinal_domestic_list_response.find('addrsenm').string # 발송인 applcnt_nm = longitudinal_domestic_list_response.find( 'applcntnm').string # 배달일자 dlvy_de = longitudinal_domestic_list_response.find('dlvyde').string # 배달상태 dlvy_sttus = longitudinal_domestic_list_response.find( 'dlvysttus').string # 종적목록 longitudinal_domestic_list = longitudinal_domestic_list_response.find_all( 'longitudinaldomesticlist') for longitudinal_domestic in longitudinal_domestic_list: # 날짜 dlvy_date = longitudinal_domestic.find('dlvydate').string # 시간 dlvy_time = longitudinal_domestic.find('dlvytime').string # 현재위치 now_lc = longitudinal_domestic.find('nowlc').string # 처리현황 process_sttus = longitudinal_domestic.find('processsttus').string # 상세설명 detail_dc = longitudinal_domestic.find('detaildc').string time = dlvy_date + ' ' + dlvy_time track = Track() track.time = time track.location = now_lc track.status = process_sttus self.add_track(track) # 우편물종류 pstmtr_knd = longitudinal_domestic_list_response.find( 'pstmtrknd').string # 등기번호 rgist = longitudinal_domestic_list_response.find('rgist').string # 취급구분 trtmnt_se = longitudinal_domestic_list_response.find('trtmntse').string parcel = Parcel() parcel.sender = applcnt_nm parcel.receiver = addrse_nm parcel.note = pstmtr_knd self.parcel = parcel