• Как из файла достать нужные данные?

    @AVKor
    import sys
    from bs4 import BeautifulSoup
    
    DOC = 'test.html'
    
    try:
        with open(DOC, encoding='utf-8') as f:
            page = f.read()
    except IOError as err:
        print(f'Error reading the file {DOC}: {err}')
        sys.exit()
    
    soup = BeautifulSoup(page, 'lxml')
    rows = soup.find_all('tr')
    rows = [row.find_all('td') for row in rows]
    rows = [row for row in rows if row]
    for row in rows:
        columns = [cell.text.strip() for cell in row]
        columns = [cell for cell in columns if cell]
        print(f'{columns[0]}:', *columns[1:-1], f'Ср: {columns[-1]}')
    Ответ написан
    Комментировать