import requests
from bs4 import BeautifulSoup


def fetch_swimmer_urls(url):
    """Fetch all of the swimmers and urls from a team url"""

    # Download/parse the pages
    page = requests.get(url)
    soup = BeautifulSoup(page.content, features="html.parser")

    # The last table in the page contains all the swimmers
    table = soup.find_all("table")[-1]

    # Each swimmer is a link in the table
    links = table.find_all("a")

    # Format: [name and year, url]
    swimmers = []
    for i in links:
        if i is not None:
            swimmers.append([i.text, "http://www.swimdata.info" + i["href"]])

    return swimmers