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, 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): 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)