С Новым годом! Форум программистов, компьютерный форум, киберфорум
Python: Web
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.60/5: Рейтинг темы: голосов - 5, средняя оценка - 4.60
 Аватар для supmener
87 / 95 / 15
Регистрация: 26.06.2013
Сообщений: 4,753

Как парсить таблицы?

15.08.2022, 07:17. Показов 1049. Ответов 5
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Хочу спарсить первую колонку "Клуб", распечатав столбиком, используя BeautifulSoup.
Хотел перебрать содержимое тегов td в цикле, например используя select('td')[2]. Только не понял, как не задействовать первую строку с
Клуб Менеджер Стадион Локация
Прикладываю скриншот.
Python
1
2
3
4
5
src = """
 
"""
soup = BeautifulSoup(src, "html.parser")
soup1 = soup.select("table")
HTML5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title></title>
  </head>
  <body>
<table class="table-custom table-roster" style="max-width:100%"><tbody><tr style="background:#fff !important"><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;height:auto" width="70"> </td><td class="text-left text-dark font-weight-normal">Клуб</td><td class="text-left text-dark font-weight-normal" style="min-width:150px !important">Менеджер</td><td class="text-left text-dark font-weight-normal" style="min-width:150px !important">Стадион</td><td class="text-left text-dark font-weight-normal" 
style="min-width:150px !important">Локация</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=9"><img alt="AFC Bournemouth" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/9.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="AFC Bournemouth" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/9.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=9">AFC Bournemouth</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=9277">Scott Parker</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=2354">Vitality Stadium</a></td><td class="text-left" style="min-width:150px !important">Bournemouth</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=1"><img alt="Arsenal" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/1.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Arsenal" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/1.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=1">Arsenal</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=8859">Mikel Arteta</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=1">Emirates Stadium</a></td><td class="text-left" style="min-width:150px !important">London</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=2"><img alt="Aston Villa" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/2.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Aston Villa" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/2.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=2">Aston Villa</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=8949">Steven Gerrard</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=2">Villa Park</a></td><td class="text-left" style="min-width:150px !important">Birmingham</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=11"><img alt="Brentford" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/11.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Brentford" class="lozad img-fluid 
img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/11.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=11">Brentford</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=6007">Thomas Frank</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=5522">Brentford Community Stadium</a></td><td class="text-left" style="min-width:150px !important">London</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=12"><img alt="Brighton and Hove Albion" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/12.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Brighton and 
Hove Albion" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/12.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=12">Brighton and Hove Albion</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=6450">Graham Potter</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=1902">AMEX Stadium</a></td><td class="text-left" style="min-width:150px !important">Brighton and Hove</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=21"><img alt="Chelsea" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/21.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Chelsea" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/21.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=21">Chelsea</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=399">Thomas Tuchel</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=7">Stamford Bridge</a></td><td class="text-left" style="min-width:150px !important">London</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=27"><img alt="Crystal Palace" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/27.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Crystal Palace" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/27.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" 
style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=27">Crystal Palace</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=8729">Patrick Vieira</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=26">Selhurst Park</a></td><td class="text-left" style="min-width:150px !important">London</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=31"><img alt="Everton" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/31.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Everton" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/31.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=31">Everton</a></td><td class="text-left" style="min-width:150px 
!important"><a href="/football-manager.php?mid=9254">Frank Lampard</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=8">Goodison Park</a></td><td class="text-left" style="min-width:150px !important">Liverpool</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=32"><img alt="Fulham" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/32.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Fulham" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/32.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=32">Fulham</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=222">Marco Silva</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=9">Craven Cottage</a></td><td class="text-left" style="min-width:150px !important">London</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=40"><img alt="Leeds United" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/40.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Leeds United" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/40.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=40">Leeds United</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=3167">Jesse Marsch</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=10">Elland Road</a></td><td class="text-left" 
style="min-width:150px !important">Leeds</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=41"><img alt="Leicester City" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/41.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Leicester City" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/41.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=41">Leicester City</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=2357">Brendan Rodgers</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=11">King Power Stadium</a></td><td class="text-left" style="min-width:150px !important">Leicester</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=44"><img alt="Liverpool" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/44.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Liverpool" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/44.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=44">Liverpool</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=392">Jürgen Klopp</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=12">Anfield</a></td><td class="text-left" style="min-width:150px !important">Liverpool</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=47"><img alt="Manchester City" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px 
!important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/47.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Manchester City" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/47.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px 
!important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=47">Manchester City</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=1914">Pep Guardiola</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=13">Etihad Stadium</a></td><td class="text-left" style="min-width:150px !important">Manchester</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=49"><img alt="Manchester United" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/49.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Manchester United" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/49.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=49">Manchester United</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=3788">Erik ten Hag</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=14">Old Trafford</a></td><td class="text-left" style="min-width:150px !important">Manchester</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=52"><img alt="Newcastle United" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/52.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Newcastle United" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/52.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=52">Newcastle United</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=9">Eddie Howe</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=16">St James' Park</a></td><td class="text-left" style="min-width:150px !important">Newcastle upon Tyne</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=55"><img alt="Nottingham Forest" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/55.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Nottingham Forest" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/55.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=55">Nottingham Forest</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=9418">Steve Cooper</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=32">The City Ground</a></td><td class="text-left" style="min-width:150px !important">Nottingham</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=72"><img alt="Southampton" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/72.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Southampton" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/72.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=72">Southampton</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=416">Ralph Hasenhüttl</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=18">St Mary's Stadium</a></td><td class="text-left" style="min-width:150px !important">Southampton</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=80"><img alt="Tottenham Hotspur" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/80.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Tottenham Hotspur" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/80.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=80">Tottenham Hotspur</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=2241">Antonio Conte</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=5208">Tottenham Hotspur Stadium</a></td><td class="text-left" style="min-width:150px !important">London</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=85"><img alt="West Ham United" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/85.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="West Ham United" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/85.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=85">West Ham United</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=31">David Moyes</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=4486">Olympic Stadium</a></td><td class="text-left" style="min-width:150px !important">London</td></tr><tr><td class="pt-0 pb-0 pr-0 pl-2 text-center" style="width:70px !important;min-width:70px !important;max-width:70px !important;" width="70"><a href="/squad.php?clubid=88"><img alt="Wolverhampton Wanderers" class="lozad img-fluid img-thumbnail" data-cfsrc="https://cdn.soccerwiki.org/images/spacer.gif" data-cfstyle="border:0;width:70px !important;padding: 6px" data-src="https://cdn.soccerwiki.org/images/logos/clubs/88.png" height="70" style="display:none;visibility:hidden;" width="70"/><noscript><img alt="Wolverhampton Wanderers" class="lozad img-fluid img-thumbnail" data-src="https://cdn.soccerwiki.org/images/logos/clubs/88.png" height="70" src="https://cdn.soccerwiki.org/images/spacer.gif" style="border:0;width:70px !important;padding: 6px" width="70"/></noscript></a></td><td class="text-left"><a href="/squad.php?clubid=88">Wolverhampton Wanderers</a></td><td class="text-left" style="min-width:150px !important"><a href="/football-manager.php?mid=9341">Bruno Lage</a></td><td class="text-left" style="min-width:150px !important"><a href="/stadium.php?stadiumdid=20">Molineux</a></td><td class="text-left" style="min-width:150px !important">Wolverhampton</td></tr></tbody></table>
  </body>
</html>
Миниатюры
Как парсить таблицы?  
1
Лучшие ответы (1)
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
15.08.2022, 07:17
Ответы с готовыми решениями:

Парсить таблицы HTML в массив
Народ, не подскажите как просто отпарсить HTML страницу в массив? Все облазил - везде какие-то сложные примеры с кучей типов и процедур....

Сложно и можно ли парсить таблицы в MS Office
Никогда не работал с MS Office. Сложно ли это сделать? Какие для этого инструменты (пару топиков об этом находил,но на счет таблиц не...

Парсить xmltable и сравнивать с данными другой таблицы в цикле
Всем доброго времени суток! Я очень начинающий в pl/sql, не судите строго за возможно простой вопрос. Задача: сравнить данные двух...

5
 Аватар для supmener
87 / 95 / 15
Регистрация: 26.06.2013
Сообщений: 4,753
15.08.2022, 12:42  [ТС]
Цитата Сообщение от supmener Посмотреть сообщение
Только не понял, как не задействоват­ь первую строку с
В принципе это можно игнорировать и писать первую строку, в которой будет слово Клуб. Не смог пока понять, как написать нормальный цикл для выборки первого столбца.
0
Эксперт по компьютерным сетям
 Аватар для Jabbson
5907 / 3359 / 1036
Регистрация: 03.11.2009
Сообщений: 10,008
16.08.2022, 07:09
Лучший ответ Сообщение было отмечено supmener как решение

Решение

Python
1
2
3
4
5
6
7
8
9
from bs4 import BeautifulSoup
 
with open('sitekey.html') as inp:
    soup = BeautifulSoup(inp.read(), 'html.parser')
 
clubs = soup.select('td:nth-of-type(2)')
 
for c in clubs:
    print(c.text)
2
 Аватар для supmener
87 / 95 / 15
Регистрация: 26.06.2013
Сообщений: 4,753
16.08.2022, 07:59  [ТС]
Для лучшего эффекта сделал по вашему совету так.
Python
1
with open('sitekey.html', encoding="utf-8") as inp:
1
 Аватар для supmener
87 / 95 / 15
Регистрация: 26.06.2013
Сообщений: 4,753
17.08.2022, 06:57  [ТС]
Видел пример отсекания первой строки, где работает по такому принципу.
Python
1
2
3
4
5
6
7
a1 = table.find_all("tr")
 
for i, tr in enumerate(a1):
    if i == 0:
        continue
    a2 = tr.find_all("td")
    print(a2[1].text)
1
Эксперт по компьютерным сетям
 Аватар для Jabbson
5907 / 3359 / 1036
Регистрация: 03.11.2009
Сообщений: 10,008
17.08.2022, 07:21
a1 это лист, если нужно пропустить первый элемент, просто начинайте со второго

Python
1
for tr in a1[1:]:
2
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
17.08.2022, 07:21
Помогаю со студенческими работами здесь

Как Парсить
http://firepic.org/images/2013-09/15/m1gxjv35nhmy.jpg Как парсить чтоб после цифр ничего не было )) вот так я делаю парс ...

Как парсить
Всем привет как парсить текст с сайта если его нету в html коде

Как Парсить
Столкнулся таким вопросом как мне парсить все что есть в k вот код procedure TForm2.sBitBtn1Click(Sender: TObject); var ...

Как парсить на питоне
Добрый день! Только не пинайте жестко! Суть вопроса такова: Есть бат файл в котором происходит сценарий, но встала проблема с добавлении...

Как парсить текст
Здравствуйте, есть текст в таком формате, подскажите как его распарсить


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
6
Ответ Создать тему
Новые блоги и статьи
Учёным и волонтёрам проекта «Einstein@home» удалось обнаружить четыре гамма-лучевых пульсара в джете Млечного Пути
Programma_Boinc 01.01.2026
Учёным и волонтёрам проекта «Einstein@home» удалось обнаружить четыре гамма-лучевых пульсара в джете Млечного Пути Сочетание глобально распределённой вычислительной мощности и инновационных. . .
Советы по крайней бережливости. Внимание, это ОЧЕНЬ длинный пост.
Programma_Boinc 28.12.2025
Советы по крайней бережливости. Внимание, это ОЧЕНЬ длинный пост. Налог на собак: https:/ / **********/ gallery/ V06K53e Финансовый отчет в Excel: https:/ / **********/ gallery/ bKBkQFf Пост отсюда. . .
Кто-нибудь знает, где можно бесплатно получить настольный компьютер или ноутбук? США.
Programma_Boinc 26.12.2025
Нашел на реддите интересную статью под названием Anyone know where to get a free Desktop or Laptop? Ниже её машинный перевод. После долгих разбирательств я наконец-то вернула себе. . .
Thinkpad X220 Tablet — это лучший бюджетный ноутбук для учёбы, точка.
Programma_Boinc 23.12.2025
Рецензия / Мнение/ Перевод Нашел на реддите интересную статью под названием The Thinkpad X220 Tablet is the best budget school laptop period . Ниже её машинный перевод. Thinkpad X220 Tablet —. . .
PhpStorm 2025.3: WSL Terminal всегда стартует в ~
and_y87 14.12.2025
PhpStorm 2025. 3: WSL Terminal всегда стартует в ~ (home), игнорируя директорию проекта Симптом: После обновления до PhpStorm 2025. 3 встроенный терминал WSL открывается в домашней директории. . .
Как объединить две одинаковые БД Access с разными данными
VikBal 11.12.2025
Помогите пожалуйста !! Как объединить 2 одинаковые БД Access с разными данными.
Новый ноутбук
volvo 07.12.2025
Всем привет. По скидке в "черную пятницу" взял себе новый ноутбук Lenovo ThinkBook 16 G7 на Амазоне: Ryzen 5 7533HS 64 Gb DDR5 1Tb NVMe 16" Full HD Display Win11 Pro
Музыка, написанная Искусственным Интеллектом
volvo 04.12.2025
Всем привет. Некоторое время назад меня заинтересовало, что уже умеет ИИ в плане написания музыки для песен, и, собственно, исполнения этих самых песен. Стихов у нас много, уже вышли 4 книги, еще 3. . .
От async/await к виртуальным потокам в Python
IndentationError 23.11.2025
Армин Ронахер поставил под сомнение async/ await. Создатель Flask заявляет: цветные функции - провал, виртуальные потоки - решение. Не threading-динозавры, а новое поколение лёгких потоков. Откат?. . .
Поиск "дружественных имён" СОМ портов
Argus19 22.11.2025
Поиск "дружественных имён" СОМ портов На странице: https:/ / norseev. ru/ 2018/ 01/ 04/ comportlist_windows/ нашёл схожую тему. Там приведён код на С++, который показывает только имена СОМ портов, типа,. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru