def monitor(url, proxy, task_num): try: initial_product_list = products.List(url, proxy) except requests.exceptions.RequestException as err: logging.info(f'SUPREME - {task_num} - {task_num}: ERROR: ' + err) while True: try: new_product_list = products.List(url, proxy) except requests.exceptions.RequestException as err: logging.info(f'SUPREME - {task_num}: ERROR: ' + err) diff = list(set(new_product_list) - set(initial_product_list)) if bool(diff) == True: logging.info(f'SUPREME - {task_num}: NEW PRODUCT FOUND!') diff = set(diff) for product in diff: check_if_posted(product) initial_product_list = new_product_list time.sleep(1) elif bool(diff) == False: # logging.info(f'no new items found found - {url}') # logging.info(f'SUPREME - {task_num}: NO CHANGES FOUND') pass else: pass
def main(proxy): proxy_formatted = proxyhandler.proxy_parse(proxy) try: products.List(site, proxy_formatted) with open('proxies_good.txt', 'a') as f: f.write(f'{proxy}\n') print(proxy, ' - GOOD PROXY') except: print(proxy, ' - BAD PROXY')
def update_urls(): global restock_urls while True: proxy_picked = proxyhandler.proxy() site = 'https://www.supremenewyork.com/mobile_stock.json' try: restock_urls = products.List(site, proxy_picked) logging.info('UPDATED URLS') time.sleep(1800) except: pass
def update_initial(): global restock_urls f****d = False while not f****d: proxy_picked = proxyhandler.proxy() site = 'https://www.supremenewyork.com/mobile_stock.json' try: restock_urls = products.List(site, proxy_picked) logging.info('INITIAL UPDATE OF URLS') f****d = True except: pass
def update_initial(): global restock_urls proxy_picked = proxyhandler.proxy() site = 'https://www.supremenewyork.com/mobile_stock.json' try: restock_urls = products.List(site, proxy_picked) logging.info('INITIAL UPDATE OF URLS') except: pass # # update restock_urls # update_initial() # updating_restock_urls = Process(target=update_urls,) # updating_restock_urls.start() # for url in restock_urls: # logging.info('STARTING RESTOCK MONITOR FOR:' + url) # restock = Process(target=restock_monitor, args=(url,)) # restock.start() # for site in sites: # for i in range(int(tasks)): # new_items = Process(target=main, args=(i+1, site, delay,)) # new_items.start() # starting workers
from pusher import Pusher import cgi from flask import Flask, render_template, request import sqlmanager import products # Create Database comparator comparator = sqlmanager.DatabaseComparator("db.sqlite3") # Create Cart List cartlist = products.List() # Create Flask implementation app = Flask(__name__, static_url_path='/static') # Set Pusher needed variables app_id = '264942' key = '61fde929ab6a2769636f' secret = 'f7a8dbe9e8d26ed46174' # Create pusher object pusher = Pusher( app_id=app_id, key=key, secret=secret ) @app.route("/") def show_index():