Parsing a tag in beautifulsoup

Hi, I have been able to capture all the a href tags that look like this:

<a href="https://www.baseballamerica.com/players/102352/gunnar-henderson/" title="Gunnar Henderson">Gunnar Henderson</a>

There are 100 of them. I’d like now to parse that to get only the 6 digit number. What line of code should I use to parse just that?

this is the line of code that gets the a href tag:

list2 = soup.find_all('div', class_='player-details')
first_id = list2[0]
id = first_id.a
print(id)

I would personally just use CSS selectors to target the div element with the player-details class and anchor tags under it. After that, just access the href attribute and use a regular expression to extract the number:

from bs4 import BeautifulSoup
import re


HTML = """
<div class="player-details">
<a href="https://www.baseballamerica.com/players/102352/gunnar-henderson/" title="Gunnar Henderson">Gunnar Henderson</a>
</div>
"""

RE_NUM = re.compile(r'/(\d{6})/')

soup = BeautifulSoup(HTML, 'html.parser')
for a in soup.select('div.player-details a'):
    print(RE_NUM.search(a['href']).group(1))
102352