Вариантов много, через CSS селекторы, xpath, от родительского элемента, по индексу из всех тегов
<a>
, по строке внутри тега, по аттрибутам
from bs4 import BeautifulSoup
from lxml import html
html_code = '''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<a href="qna.habr.com">qna</a>
<div id="main">
<a href="habr.com" target="_blank">example</a>
<a href="career.habr.com">career</a>
</div>
<a href="freelance.habr.com">freelance</a>
</body>
</html>
'''
soup = BeautifulSoup(html_code, 'html.parser')
tree = html.fromstring(html_code)
# xpath
element = tree.xpath('/html/body/div/a[1]')[0]
print(element.get('href'))
# from parent
element = soup.find('div', id='main').find('a')
print(element.get('href'))
# index
element = soup.find_all('a')[1]
print(element.get('href'))
# string
element = soup.find('a', string='example')
print(element.get('href'))
# attrs
element = soup.find('a', target='_blank')
print(element.get('href'))