python下载图片脚本_Python脚本在后台下载图片,挂断。如何继续下载脚本?

我在运行一个python脚本(下载器.py)在数据采集服务器的后台。它会浏览链接列表并下载每个图片。(下面的代码片段)由于有很多图像,我运行的是“nohup python”下载器.py&“因为没有挂机,而且在后台。在

一切开始都很好,但是在任意数量的图像之后,图像停止下载。当我运行“ps aux | grep”时,进程PID仍然显示为正在运行的进程下载器.py“,但是不出来输出文件刚刚打印了下一个文件的链接,正如代码片段中的“print(myfile+”“+link)”所输出的那样。(没有错误消息显示在不出来,它只会停止下载或继续链接文件中的下一个图像)。有什么问题吗?unix中进程的“nice”优先级设置为0。在for link in read_lines("data_links/"+myfile):

try:

print(myfile + " " + link)

counter = counter + 1

##downloading the image and saving the file in data_collection/

print("set file structure for download")

f = open("data_collection/" + myfile.replace("_links.txt", "") + "/" + str(counter) + ".jpg", 'wb')

print("beginning url request")

f.write(request.urlopen(link).read())

print("url request done, closing file")

f.close()

print("done downloading, moving onto next")

except:

print("downloading error, but no problem, we're moving on to the next one")

continue

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值