import re


def _get_authenticity_token(session):
    """ Parse the page to get the authenticity token. """

    response = session.get('https://www.recurse.com/login')
    matches = re.findall('<meta\s*?name="(.*?)"\s*content="(.*)".*/>', response.text)

    for name, content in matches:
        if name == 'csrf-token':
            return content

    raise ValueError('Could not find authenticity token')