如何下载其中包含查询字符串的图像

How to download an image with querystring in it

我正在尝试从以下 url 下载图像并调整其大小:http://musicimage.xboxlive.com/catalog/video.tvepisode.8D6KGWZK9B10/image?locale=en-CA&purposes=BoxArt

在浏览器中查看效果很好,但在本地下载时效果不佳。这是我正在尝试做的事情:

$ curl -O http://musicimage.xboxlive.com/catalog/video.tvepisode.8D6KGWZK9B10/image?locale=en-CA&purposes=BoxArt

>>> from PIL import Image
>>> img = Image.open(tmp_filename).convert('RGB')

如何下载上述文件以便在本地将其处理为图像?

尝试对请求执行此操作:

>>> res=requests.get('http://musicimage.xboxlive.com/catalog/video.tvepisode.8D6KGWZK9B10/image?locale=en-CA&purposes=BoxArt')
>>> res
<Response [200]>
>>> open('file.jpg','w').write(res.content)