使用Python和urllib2下载低优先级文件
我正在编写一个简单的工具来保留我复制的每张图像(图像的 URL) 我正在使用 pythoncom 和 pyhook 来捕获键盘“复制”组合。 这里的问题是,当图像开始下载时,它会导致速度大幅下降,因此我必须等待 0.5-2 秒才能完成脚本。代码如下:
response = urllib2.urlopen (URL)
image_file = response.read()
file = open (path + filename, 'wb')
file.write (image_file)
file.close()
那么,问题是 - 有没有办法消除这种延迟?
I'm writing simple tool to keep every image that I've copied (URL of image)
I'm using pythoncom and pyhook to catch keyboard "Copy" combination.
The problem here is that when Image starts downloading it causes major slowdown, so I have to wait for 0.5-2 seconds for script to finish. Here's the code:
response = urllib2.urlopen (URL)
image_file = response.read()
file = open (path + filename, 'wb')
file.write (image_file)
file.close()
So, the question is - is there a way to get rid of this delay?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前的问题(未经编辑)并不是那么清楚。但我的印象是你的问题是你必须在处理图像之前从某个地方下载图像。为了解决这个问题,我将使用以下两种方法之一:
The question in its current state (unedited) is not really that clear. But I am under the impression your problem is the fact you have to download the image from somewhere before processing it. To get around that, I would use either of the two: