I am trying to extract the links using a specific work in each link in the list of links. Below is the code that I get the URLs:
import urllib
from bs4 import BeautifulSoup as bs
url ='https://fbref.com/en/squads/b8fd03ef/Manchester-City-Stats'
html_page = urllib.request.urlopen(url)
soup = bs(html_page, "html.parser")
links = []
player_link =[]
for link in soup.findAll('a'):
links.append(link.get('href'))
From the above lines of code, I can store the list of links in the variable links I want to create a new list containing only the specific word summary. The expected output ( only part of all) that should be stored in a new list player_list is shown below:
player_list =['/en/players/3bb7b8b4/matchlogs/2021-2022/summary/Ederson-Match-Logs',
'/en/players/3eb22ec9/matchlogs/2021-2022/summary/Bernardo-Silva-Match-Logs',
'/en/players/bd6351cd/matchlogs/2021-2022/summary/Joao-Cancelo-Match-Logs',
'/en/players/31c69ef1/matchlogs/2021-2022/summary/Ruben-Dias-Match-Logs',
'/en/players/6434f10d/matchlogs/2021-2022/summary/Rodri-Match-Logs',
'/en/players/119b9a8e/matchlogs/2021-2022/summary/Aymeric-Laporte-Match-Logs']
I tried exploring some of the previous posts, but it did not work out. What can I try next?