def ScanStore(filename, collectionLink, webhook, sizeOption, productLink, storeName): global pageNum print('Scanning Store: ' + storeName) while True: time.sleep(2) pageNum += 1 FileCheck(filename) request = requests.get(collectionLink + 'products.json?limit=250&page=' + str(pageNum)) try: decodedJson = request.json() except Exception: print('[ERROR] Unable to parse JSON!!') return if len(decodedJson['products']) == 0: pageNum = 0 return for product in decodedJson['products']: #if all(x not in product['vendor'].lower() for x in brands): # continue ItemName = product['title'] ItemColor = product['handle'] SoldOut = True sizeString = '' for variant in product['variants']: #print(variant['available']) if variant['available'] == True: SoldOut = False size = variant[sizeOption] if sizeOption == 'option2': if size is None: size = variant['option1'] if size is None: size = 'F' if size not in sizeString: if sizeString == '': sizeString += size else: sizeString += '|' + size if product['variants'][0]['featured_image'] is not None: ItemPicture = product['variants'][0]['featured_image']['src'] else: try: ItemPicture = product['images'][0]['src'] except IndexError: ItemPicture = '' ItemPrice = '$' + product['variants'][0]['price'] ItemLink = productLink + product['handle'] temp = SiteItem(ItemName, ItemColor, SoldOut) index = ExistsInList(temp) # If item already exists in list if index != -1: oldSoldOut = ItemList[index].SoldOut if SoldOut != oldSoldOut: if not SoldOut: try: SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'RESTOCK', ItemLink, ItemPicture, sizeString, webhook, storeName, collectionLink) print('[RESTOCK]' + ItemName) if 'jordan' in ItemName.lower(): SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'RESTOCK', ItemLink, ItemPicture, sizeString, jordan, storeName, collectionLink) if 'yeezy' in ItemName.lower(): SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'RESTOCK', ItemLink, ItemPicture, sizeString, yeezy, storeName, collectionLink) if 'nike' in ItemName.lower() and ( 'sb' in ItemName.lower() or 'dunk' in ItemName.lower()): SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'RESTOCK', ItemLink, ItemPicture, sizeString, nikesb, storeName, collectionLink) if 'off-white' in ItemName.lower() or ( 'off' in ItemName.lower() and 'white' in ItemName.lower()): SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'RESTOCK', ItemLink, ItemPicture, sizeString, offwhite, storeName, collectionLink) except: print( 'ERROR: Couldn\'t send message. Product Type: ' + product['product_type'].lower()) else: try: SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'Sold Out', ItemLink, ItemPicture, sizeString, webhook, storeName, collectionLink) print('[SOLD OUT]' + ItemName) if 'jordan' in ItemName.lower(): SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'Sold Out', ItemLink, ItemPicture, sizeString, jordan, storeName, collectionLink) if 'yeezy' in ItemName.lower(): SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'Sold Out', ItemLink, ItemPicture, sizeString, yeezy, storeName, collectionLink) if 'nike' in ItemName.lower() and ( 'sb' in ItemName.lower() or 'dunk' in ItemName.lower()): SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'Sold Out', ItemLink, ItemPicture, sizeString, nikesb, storeName, collectionLink) if 'off-white' in ItemName.lower() or ( 'off' in ItemName.lower() and 'white' in ItemName.lower()): SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'Sold Out', ItemLink, ItemPicture, sizeString, offwhite, storeName, collectionLink) except: print( 'ERROR: Couldn\'t send message. Product Type: ' + product['product_type'].lower()) ItemList.pop(index) ItemList.append(temp) else: if not SoldOut: try: SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'In Stock', ItemLink, ItemPicture, sizeString, webhook, storeName, collectionLink) print('[IN STOCK]' + ItemName) if 'jordan' in ItemName.lower(): SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'In Stock', ItemLink, ItemPicture, sizeString, jordan, storeName, collectionLink) if 'yeezy' in ItemName.lower(): SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'In Stock', ItemLink, ItemPicture, sizeString, yeezy, storeName, collectionLink) if 'nike' in ItemName.lower() and ( 'sb' in ItemName.lower() or 'dunk' in ItemName.lower()): SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'In Stock', ItemLink, ItemPicture, sizeString, nikesb, storeName, collectionLink) if 'off-white' in ItemName.lower() or ( 'off' in ItemName.lower() and 'white' in ItemName.lower()): SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'In Stock', ItemLink, ItemPicture, sizeString, offwhite, storeName, collectionLink) except: print('ERROR: Couldn\'t send message. Product Type: ' + product['product_type'].lower()) ItemList.append(temp) FileWrite(filename)
#print(ItemName) SoldOut = True sizeString = '' for variant in product['variants']: #print(variant['available']) if variant['available'] == True: SoldOut = False if sizeString == '': sizeString += variant['title'] else: sizeString += '|' + variant['title'] ItemPicture = product['images'][0]['src'] ItemPrice = '$' + product['variants'][0]['price'] ItemLink = 'https://kith.com/products/' + product['handle'] temp = SiteItem(ItemName, ItemColor, SoldOut) index = ExistsInList(temp) # If item already exists in list if index != -1: oldSoldOut = ItemList[index].SoldOut if SoldOut != oldSoldOut: if not SoldOut: try: SendDiscordMessage(ItemName, ItemColor, ItemPrice, 'RESTOCK', ItemLink, ItemPicture, sizeString, webhook) print('[RESTOCK]' + ItemName) except:
SoldOut = False size = variant['title'] if size not in sizeString: if sizeString == '': sizeString += size else: sizeString += '|' + size try: ItemPicture = product['images'][0]['src'] except IndexError: ItemPicture = '' ItemPrice = '$' + product['variants'][0]['price'] ItemLink = 'https://shop-usa.palaceskateboards.com/products/' + product[ 'handle'] temp = SiteItem(ItemName, '', SoldOut) index = ExistsInList(temp) # If item already exists in list if index != -1: oldSoldOut = ItemList[index].SoldOut if SoldOut != oldSoldOut: if not SoldOut: SendDiscordMessage(ItemName, ItemPrice, 'RESTOCK', ItemLink, ItemPicture, sizeString, webhook) else: SendDiscordMessage(ItemName, ItemPrice, 'Sold Out', ItemLink, ItemPicture, sizeString,