Collect <a> tags, then .get("href"). Skip empty hrefs and mailto: if you only want paths.
Goal
Print every href, then keep only in-site paths.
All hrefs
html = """
<nav>
<a href="/nairobi/">Nairobi</a>
<a href="/mombasa/">Mombasa</a>
<a href="mailto:kiosk@example.com">Contact</a>
<a>No href</a>
</nav>
"""
soup = BeautifulSoup(html, "html.parser")
for a in soup.find_all("a"):
print(a.get("href"), a.get_text(strip=True))Paths only
html = """
<footer>
<a href="/nairobi/">Nairobi</a>
<a href="https://example.com">External</a>
<a href="mailto:kiosk@example.com">Contact</a>
</footer>
"""
soup = BeautifulSoup(html, "html.parser")
paths = []
for a in soup.find_all("a"):
href = a.get("href") or ""
if href.startswith("/"):
paths.append((a.get_text(strip=True), href))
print(paths)Relative links start with / or a file name. Absolute links start with http. Mail links start with mailto:.
You should see
Attach kiosk.html in the Files chapter to scrape a real nav.