Last active
July 24, 2017 16:15
-
-
Save footcarts/c4c26b1183710548c11dc1d203e8d528 to your computer and use it in GitHub Desktop.
adidas_image.py
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 os | |
import sys | |
import argparse | |
import requests | |
import argparse | |
import requests | |
import os | |
import sys | |
def scrape(prefix): | |
end = 9999 | |
i = 0000 | |
iFill = str(i).zfill(4) | |
while i <= end: | |
iFill = str(i).zfill(4) | |
link = "http://www.adidas.nl/dis/dw/image/v2/aagl_prd/on/demandware.static/-/Sites-adidas-products/default/zoom/" | |
link2 = "_01_standard.jpg?sw=200&sfrm=jpg" | |
link3 = link + prefix + str(iFill) + link2 | |
styles = "adidas_" + prefix +str(i) +".jpg" | |
if os.path.isfile(styles): | |
i = i + 1 | |
print prefix + str(i) + " : ALREADY FOUND... SKIPPING" | |
continue | |
r = requests.get(link3,stream=True) | |
if r.status_code == 200: | |
with open(styles, 'wb') as f: | |
for chunk in r: | |
f.write(chunk) | |
print prefix + str(i) + " : IMAGE FOUND" | |
else: | |
print prefix + str(i) + " : NOTHING HERE" | |
i = i + 1 | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser( | |
description='Adidas Scraper') | |
parser.add_argument('-p', required=True, | |
type=str,help='what prefix') | |
args = parser.parse_args() | |
sys.exit(scrape(args.p)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment