-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsku.py
37 lines (24 loc) · 906 Bytes
/
sku.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from PIL import Image
import requests
from io import BytesIO
import xlsxwriter as xwrite
import json
import os
import time
row = 1
col = 0
with open("skulist.json") as list: #### READS SKU LIST
skusdata = json.load(list)
skus = skusdata['skus']
workbook = xwrite.Workbook('Sku_List.xlsx') ##### CREATES EXCEL FILE
worksheet = workbook.add_worksheet()
for sku in skus: #### GOES THROUGH SKU LIST
imageURL = (f"https://images.footlocker.com/is/image/EBFL2/{sku}?wid=60&hei=60&fmt=png-alpha")
r = requests.get(imageURL)
img = Image.open(BytesIO(r.content))
imgSave = img.save(f"SKU: {sku}.png") #### PULLS IMAGE FROM URL
worksheet.insert_image(row - 1, col + 2, f"SKU: {sku}.png")
worksheet.write(row, col, sku)
print(f'{sku} : Done', end= '\n')
row += 2 # GOES DOWN TWO ROWS
workbook.close() #### WRITES EXCEL FILE