def extract_details_data(details): soup = BeautifulSoup(details, 'lxml') detainees_all = soup.find_all('div', class_='detaineeInfo') for detainee in detainees_all: detainee_info_table = detainee.find('table', class_='collapse centered_table shadow') detainee_trs = detainee_info_table.find_all('tr') data = {} for tr in detainee_trs: key = tr.find('td', class_='one td_left').text.lower().strip() value = tr.find('td', class_='two td_left').text.strip() data[key] = value info = Info.create(**data)
def send_info(self, bot: Bot, info_list: list): """Send info request.""" info = Info(bot.id(), info_list) bot.on_info_received(info) bot.write(info.create())