def search_content(key, content, fmat='attr'):
    """
    @brief      Search content from xml or html format
    @param      key      String
    @param      content  String
    @param      fmat     attr
                         xml
    @return     String
    """
    if fmat == 'attr':
        pm = re.search(key + '\s?=\s?"([^"<]+)"', content)
        if pm:
            return pm.group(1)
    elif fmat == 'xml':
        pm = re.search('<{0}>([^<]+)</{0}>'.format(key), content)
        if not pm:
            pm = re.search(
                '<{0}><\!\[CDATA\[(.*?)\]\]></{0}>'.format(key), content)
        if pm:
            return pm.group(1)
    return 'unknown'

    @brief      Search content from xml or html format
    @param      key      String
    @param      content  String
    @param      fmat     attr
                         xml
    @return     String
    
wxbot_project_py2.7/wechat/utils.py