def get(url, api=None):
    """
    @brief      http get request
    @param      url   String
    @param      api   wechat api
    @return     http response
    """
    Log.debug('GET -> ' + url)
    request = urllib2.Request(url=url)
    request.add_header(*Constant.HTTP_HEADER_CONNECTION)
    request.add_header(*Constant.HTTP_HEADER_REFERER)
    if api in ['webwxgetvoice', 'webwxgetvideo']:
        request.add_header(*Constant.HTTP_HEADER_RANGE)

    while True:
        try:
            response = urllib2.urlopen(request, timeout=30)
            data = response.read()
            response.close()
            if api == None:
                Log.debug(data)
            return data
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            Log.error(traceback.format_exc())

        time.sleep(1)

    @brief      http get request
    @param      url   String
    @param      api   wechat api
    @return     http response
    
wxbot_project_py2.7/wechat/utils.py