It is built-in with Unix-based OS and now it has a version built for Windows OS too.įrom urllib import request URL = ' ' response = request.urlretrieve( ' ', 'facebook.ico') Output The Wget is a non-interactive tool that can be used to download remote files from the internet. Download a file from URL using wget in Python Hence you can see how to use the response package to download the file. We created a file named facebook.ico and have written the data into the file. We open a file in write binary mode and write the contents from the URL to the file. We use requests.get() function to send a get request to the URL link. We provided the link for the Facebook icon image. In the next line, we specified the link for the image file. In this program, we imported a requests package that handles the GET or POST requests. It will download the facebook’s favicon.ico file in your current working directory.
Import requests URL = ' ' response = requests.get(URL) open('facebook.ico', 'wb').write(ntent) Output