Skip to content

Instantly share code, notes, and snippets.

@MhmdRyhn
Created July 26, 2019 02:32
Show Gist options
  • Save MhmdRyhn/085fdf930afda675bd6ec52f1a9a20ee to your computer and use it in GitHub Desktop.
Save MhmdRyhn/085fdf930afda675bd6ec52f1a9a20ee to your computer and use it in GitHub Desktop.
Download an image from URL
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