from bs4 import BeautifulSoup
import re


def extract_csv_urls(page, root_url):
    """Extract urls for downloading csv files and append a root url.

    Keyword arguments:
    page -- Webpage as a raw HTML
    root_url -- URL to append to output url
    """
    soup = BeautifulSoup(page,"html.parser")
    urls = [link.get("href") for link in soup.find_all("a")]
    csv_urls = [root_url + url for url in urls if re.match(r".*\.csv", url)!=None]
    return csv_urls