如何用Python下载这张图片?

How to download this image with Python?

我有一个直接的 link 这样的:https://picjumbo.com/download/?d=cow.jpg&n=cow&id=1。但是我无法使用urllib.request.urlretrieve()下载它,因为当我访问这个url时,浏览器会自动下载它。

您可以执行以下操作:

>>> import requests
>>> content = requests.get('https://picjumbo.com/wp-content/themes/picjumbofree/run.php?download&d=cow.jpg&n=cow').content
>>> with open('downloaded_img.jpg', 'wb') as img:
...     img.write(content)
... 
8153739
>>>