pin*_*gze -1 python gif python-imaging-library
我给一个网址作为例子:
http://ww4.sinaimg.cn/large/a7bf601fjw1f7jsbj34a1g20kc0bdnph.gif
Run Code Online (Sandbox Code Playgroud)
您可以在浏览器中看到它.
现在我想下载它.我试过了:
1.
urllib.urlretrieve(imgurl,filepath')
失败了,得到了一个"错误"的图片.
2.
wget.download(imgurl)
失败了,得到了一个"错误"的图片.
3.
r = requests.get(imgurl,stream=True)
img = PIL.Image.open(StringIO(r.content))
img.save(filepath)
失败,得到一张静态图片,我的意思是,只有一帧.
所以我该怎么做?
这对我来说非常好,可以获得动画gif:
>>> import requests
>>> uri = 'http://ww4.sinaimg.cn/large/a7bf601fjw1f7jsbj34a1g20kc0bdnph.gif'
>>> with open('/tmp/pr0n.gif', 'wb') as f:
... f.write(requests.get(uri).content)
...
Run Code Online (Sandbox Code Playgroud)
快乐的消息!