-2

I have a direct link like this: https://picjumbo.com/download/?d=cow.jpg&n=cow&id=1. But I cannot download it using urllib.request.urlretrieve() because when I access this url, the browser will download it automatically.

AXin
  • 23
  • 1
  • 6
  • why would you open the browser if you just want to write a script to download a certain image? – Hozayfa El Rifai May 02 '20 at 16:07
  • My code is used to automatically download images from a web page automatically. The above question is only a small one in my general code. I will not waste time writing code to load only a single image. But thank. – AXin May 03 '20 at 15:54

1 Answers1

1

You can do the following:

>>> 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
>>> 
  • Yeah, I noticed that and I was intending to change it after copying here but I forgot –  May 02 '20 at 16:27