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

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

15.08.2022, 07:17. Показов 1058. Ответов 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,755
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,755
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,755
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
Ответ Создать тему
Новые блоги и статьи
SDL3 для Desktop (MinGW): Создаём пустое окно с нуля для 2D-графики на SDL3, Си и C++
8Observer8 10.03.2026
Содержание блога Финальные проекты на Си и на C++: hello-sdl3-c. zip hello-sdl3-cpp. zip Результат:
Установка CMake и MinGW 13.1 для сборки С и C++ приложений из консоли и из Qt Creator в EXE
8Observer8 10.03.2026
Содержание блога MinGW - это коллекция инструментов для сборки приложений в EXE. CMake - это система сборки приложений. Здесь описаны базовые шаги для старта программирования с помощью CMake и. . .
Как дизайн сайта влияет на конверсию: 7 решений, которые реально повышают заявки
Neotwalker 08.03.2026
Многие до сих пор воспринимают дизайн сайта как “красивую оболочку”. На практике всё иначе: дизайн напрямую влияет на то, оставит человек заявку или уйдёт через несколько секунд. Даже если у вас. . .
Модульная разработка через nuget packages
DevAlt 07.03.2026
Сложившийся в . Net-среде способ разработки чаще всего предполагает монорепозиторий в котором находятся все исходники. При создании нового решения, мы просто добавляем нужные проекты и имеем. . .
Модульный подход на примере F#
DevAlt 06.03.2026
В блоге дяди Боба наткнулся на такое определение: В этой книге («Подход, основанный на вариантах использования») Ивар утверждает, что архитектура программного обеспечения — это структуры,. . .
Управление камерой с помощью скрипта OrbitControls.js на Three.js: Вращение, зум и панорамирование
8Observer8 05.03.2026
Содержание блога Финальная демка в браузере работает на Desktop и мобильных браузерах. Итоговый код: orbit-controls-threejs-js. zip. Сканируйте QR-код на мобильном. Вращайте камеру одним пальцем,. . .
SDL3 для Web (WebAssembly): Синхронизация спрайтов SDL3 и тел Box2D
8Observer8 04.03.2026
Содержание блога Финальная демка в браузере. Итоговый код: finish-sync-physics-sprites-sdl3-c. zip На первой гифке отладочные линии отключены, а на второй включены:. . .
SDL3 для Web (WebAssembly): Идентификация объектов на Box2D v3 - использование userData и событий коллизий
8Observer8 02.03.2026
Содержание блога Финальная демка в браузере. Итоговый код: finish-collision-events-sdl3-c. zip Сканируйте QR-код на мобильном и вы увидите, что появится джойстик для управления главным героем. . . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru