How to download a image in flickr by Python urllib.urlretrieve()?

若如初见. 提交于 2019-12-11 13:01:57

问题


I have a problem that when dowloading a image from flickr.com,the python function urllib.urlretrieve() always return an error

[Errno socket error] (10060, 'Operation timed out')

for example:

import urllib

url = "http://farm3.static.flickr.com/2659/4207030547_23e6000d29_o.gif"
urllib.urlretrieve(url,"C://tmp.gif")

I am Chinese,and I dont know if the "time out" has anything to do with the speed of the the internet in China.

Now it falied in downing the .gif! what should i do about this? THX~~~

Any suggestion is appreciated~~~


回答1:


I can't reproduce.

The exact same code downloaded the picture.

I'm using python 2.7

It has to do either with the server (at that time) or with your internet connection.




回答2:


Consider using the urllib2 library instead, which allows you to specify the timeout (in Python 2.6+).



来源:https://stackoverflow.com/questions/7749649/how-to-download-a-image-in-flickr-by-python-urllib-urlretrieve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!