from bs4 import BeautifulSoup


def parse_profile(res):
    """Parse profile from procyclingstats.com response."""
    soup = BeautifulSoup(res.text, "html.parser")
    profile_tag = soup.select("div.statDivLeft img:first-of-type")

    # Check if profile exists
    if not profile_tag:
        return 404

    profile = profile_tag[0]["src"]
    return {
        "profile": profile
    }