Created
May 26, 2022 18:26
-
-
Save Todoviernes/9c67b6d981cbd35032925564fda8d6cb to your computer and use it in GitHub Desktop.
This file contains 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 | |
import urllib | |
import urllib.request | |
from slugify import slugify | |
url = "https://example.com/api/v1/images" | |
payload={} | |
headers = { | |
'Authorization': 'XXXXXXXX' | |
} | |
response = requests.request("GET", url, headers=headers, data=payload) | |
products = response.json()['data']["products"] | |
for i in products: | |
name = i['name'] | |
slug = slugify(name) | |
resource = urllib.request.urlopen(i['images'][0]) | |
output = open(slug +".jpg", "wb") | |
output.write(resource.read()) | |
output.close() | |
print('Image Saved!!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment