def search_userid(username):
    headers = {'X-Requested-With': 'XMLHttpRequest',
               'Origin': FORUM_URL,
               'Referer': FORUM_URL + '/search.php'
               }

    data = {'securitytoken': 'guest',
            'do': 'usersearch',
            'fragment': username
            }

    response = requests.post(AJAX_USERSEARCH_URL, data, headers=headers)
    root = etree.fromstring(response.content)

    try:
        found_name = root[0].text
    except __HOLE__:
        raise UserNotFoundError(username)

    # The request is basically a search, can return multiple userids
    # for users starting with username. Make sure we got the right one!
    if found_name.upper() != username.upper():
        exc = AmbiguousUserNameError(username)
        # attach the extra users to the exception
        ExtraUser = namedtuple('ExtraUser', 'name, id')
        exc.users = tuple(ExtraUser(name=child.text, id=child.attrib['userid']) for child in root)
        raise exc

    userid = root[0].attrib['userid']
    # userid is str on Python2, we need to decode to make it unicode
    return userid.decode('utf-8')
dataset/ETHPy150Open pokerregion/poker/poker/website/twoplustwo.py/search_userid