def scrape(document):
    """Scrape the HTML document returned from ur1.ca for the answer.

    document: HTML document returned from ur1.ca

    Returns a 2-tuple (success, answer) where --

    success: boolean value indicating whether the service returned
    some meaningful result

    answer: if success, this is the shortened URL, otherwise a string
    indicating the possible problem

    """
    goodguess = RE_GOOD.search(document)
    if goodguess:
        matchdict = goodguess.groupdict()
        return (True, matchdict["shorturl"])
    badguess = RE_BAD.search(document)
    if badguess:
        matchdict = badguess.groupdict()
        return (False, matchdict["errormsg"])
    else:
        return (False, "Unknown local error.")
Scrape the HTML document returned from ur1.ca for the answer.

    document: HTML document returned from ur1.ca

    Returns a 2-tuple (success, answer) where --

    success: boolean value indicating whether the service returned
    some meaningful result

    answer: if success, this is the shortened URL, otherwise a string
    indicating the possible problem

    
recipes/Python/577236_ur1ca_commandline_client/recipe-577236.py