Если стоит цель собрать только ссылки на матчи из таблицы, то сделать это можно вот так:
import requests
from bs4 import BeautifulSoup
def get_html(url):
r = requests.get(url)
return r.text
def get_match_links(html):
soup = BeautifulSoup(html, 'lxml')
match_links = [tag.get('href') for tag in soup.find_all('a', class_='link')]
return match_links
def main():
url = 'http://www.kicker.de/news/fussball/2bundesliga/spieltag/2-bundesliga/2016-17/1/0/spieltag.html'
match_links = get_match_links(get_html(url))
return match_links
if __name__ == '__main__':
links=main()
print(links)
аутпут:
['/news/fussball/2bundesliga/spieltag/2-bundesliga/2016-17/1/3317254/spielanalyse_1-fc-kaiserslautern-37_hannover-96-58.html', '/news/fussball/2bundesliga/spieltag/2-bundesliga/2016-17/1/3317256/spielanalyse_vfl-bochum-8_1-fc-union-berlin-62.html', '/news/fussball/2bundesliga/spieltag/2-bundesliga/2016-17/1/3317261/spielanalyse_sv-sandhausen-1604_fortuna-duesseldorf-13.html', '/news/fussball/2bundesliga/spieltag/2-bundesliga/2016-17/1/3317262/spielanalyse_dynamo-dresden-65_1-fc-nuernberg-81.html', '/news/fussball/2bundesliga/spieltag/2-bundesliga/2016-17/1/3317258/spielanalyse_spvgg-greuther-fuerth-82_1860-muenchen-5.html', '/news/fussball/2bundesliga/spieltag/2-bundesliga/2016-17/1/3317257/spielanalyse_eintracht-braunschweig-41_wuerzburger-kickers-7283.html', '/news/fussball/2bundesliga/spieltag/2-bundesliga/2016-17/1/3317259/spielanalyse_1-fc-heidenheim-11306_erzgebirge-aue-64.html', '/news/fussball/2bundesliga/spieltag/2-bundesliga/2016-17/1/3317260/spielanalyse_arminia-bielefeld-10_karlsruher-sc-6.html', '/news/fussball/2bundesliga/spieltag/2-bundesliga/2016-17/1/3317255/spielanalyse_vfb-stuttgart-11_fc-st-pauli-18.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/hannover-96-58/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/vfl-bochum-8/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/eintracht-braunschweig-41/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/vfb-stuttgart-11/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/spvgg-greuther-fuerth-82/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/1-fc-heidenheim-11306/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/fortuna-duesseldorf-13/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/sv-sandhausen-1604/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/dynamo-dresden-65/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/1-fc-nuernberg-81/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/arminia-bielefeld-10/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/karlsruher-sc-6/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/1-fc-union-berlin-62/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/fc-st-pauli-18/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/wuerzburger-kickers-7283/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/erzgebirge-aue-64/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/1860-muenchen-5/vereinsinformationen.html', '/news/fussball/2bundesliga/vereine/2-bundesliga/2016-17/1-fc-kaiserslautern-37/vereinsinformationen.html']
return
функция прекращает работу и до принта не доходит. уберитеreturn
, и оставьте принт, или уберите принт и напишитеprint(main())