Exemple #1
0
def downLoadResource(fileName, url, goalTime=3, passIfExist=True):
    '''
    @Deprecated
    @see thisModalName2
    :param
    fileName:
    :param
    url:
    :param
    goalTime:
    :param
    passIfExist:
    :return:
    '''
    if os.path.exists(fileName):
        return False

    for i in range(0, goalTime):

        if (i > 0):
            print 'now index is %d for %s' % (i, fileName)

        try:
            urllib.urlretrieve(url, fileName)
            print 'downloaded %s' % fileName
            return True
        except Exception, e:
            # urllib.urlretrieve(urlT,fileName.decode('utf-8'))
            try:
                os.remove(fileName)
            except Exception, e:
                zTools.commonErrorPrint(e)

            zTools.commonErrorPrint(e)
Exemple #2
0
def tryGetHtml(url, tryCount=3):
    '''
    @Deprecated
    @see thisModalName2
    :param url:
    :param tryCount:
    :return:
    '''
    for i in range(0, tryCount):

        if i > 0:
            print '%s,now index is %s' % (sys._getframe().f_back.f_code.co_name, i)

        try:
            c = getHtml(url)
            return c
        except Exception, e:
            zTools.commonErrorPrint(e)