def downloadFile(curPostUrl, picInfoDict, dstPicFile) : curUrl = picInfoDict['picUrl']; #if not add follow user-agent, then download file will 403 forbidden error headerDict = { 'Referer' : curPostUrl, 'User-Agent' : "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1", }; return crifanLib.manuallyDownloadFile(curUrl, dstPicFile, headerDict);
def downloadFile(curPostUrl, picInfoDict, dstPicFile): curUrl = picInfoDict['picUrl'] #if not add follow user-agent, then download file will 403 forbidden error headerDict = { 'Referer': curPostUrl, 'User-Agent': "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1", } return crifanLib.manuallyDownloadFile(curUrl, dstPicFile, headerDict)
def downloadFile(curPostUrl, picInfoDict, dstPicFile) : curUrl = picInfoDict['picUrl']; if(picInfoDict['isSelfBlog']): logging.debug("curPostUrl=%s, curUrl=%s, dstPicFile=%s", curPostUrl, curUrl, dstPicFile); # must use post url as referer, otherwise will get HTTP Error 403: Forbidden headerDict = { 'Referer' : curPostUrl, }; return crifanLib.manuallyDownloadFile(curUrl, dstPicFile, headerDict); else: return crifanLib.downloadFile(curUrl, dstPicFile);