Created
July 26, 2019 02:32
-
-
Save MhmdRyhn/085fdf930afda675bd6ec52f1a9a20ee to your computer and use it in GitHub Desktop.
Download an image from URL
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
import requests | |
def download_single_image(self, url, file_name): | |
with open(self.image_path + file_name.replace(' ', '_') + '.jpg', 'wb') as file: | |
response = requests.get(url, stream=True) | |
for block in response.iter_content(1024): | |
if not block: | |
break | |
file.write(block) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment