Categories
Python Answers

How to download a picture via urllib and Python?

Spread the love

Sometimes, we want to download a picture via urllib and Python.

In this article, we’ll look at how to download a picture via urllib and Python.

How to download a picture via urllib and Python?

To download a picture via urllib and Python, we can use the urllib.request.urlretrieve method.

For instance, we write

import urllib.request

urllib.request.urlretrieve("https://picsum.photos/200/300", "pic.jpg")

to call urllib.request.urlretrieve with the URL of the image and the file name to save it as.

Conclusion

To download a picture via urllib and Python, we can use the urllib.request.urlretrieve method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *