Created
April 10, 2020 16:03
-
-
Save ChaitanyaBaweja/5751ae5e5dc1c9c835071dd49be46517 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Importing required libraries | |
import urllib.request | |
# Adding information about user agent | |
opener=urllib.request.build_opener() | |
opener.addheaders=[('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1941.0 Safari/537.36')] | |
urllib.request.install_opener(opener) | |
# setting filename and image URL | |
filename = 'sunshine_dog.jpg' | |
image_url = "https://cdn.pixabay.com/photo/2020/02/06/09/39/summer-4823612_960_720.jpg" | |
# calling urlretrieve function to get resource | |
urllib.request.urlretrieve(image_url, filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment