<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">from newMarketBot import NewMarketBot
import time
import queue
import threading
from ThreadMonitor import ThreadMonitor
from LoggingFormatter import logger
from AWSInit import createAWSSessions
import Queues
import HelperFunctions
import GetWebshareIPs


all_sessions = createAWSSessions()
all_threads = []

def startScraper(filename: str, bs_and_fn: bool):
    webshare_ips = GetWebshareIPs.getWebshareProxies()
    
    global all_threads
    all_threads += Queues.startCsgofloatQueue(all_sessions=all_sessions, webshare_ips=webshare_ips)
    all_threads += Queues.startHandleListingsQueue(all_sessions=all_sessions, webshare_ips=webshare_ips)


    f = open(filename, "r")
    lines = f.readlines()
    f.close()

    lines = [x.strip() for x in lines]
    # splitted_weapons = [lines[(i*len(lines))//2:((i+1)*len(lines))//2] for i in range(2)]

    extended_scrape = False

    while True:
        if bs_and_fn:
            floatval = "high"
            runThreads(
                lines,
                floatval,
                webshare_ips,
                all_sessions,
                extended_scrape,
                Queues.listings_queue,
                Queues.csgofloat_queue,
            )

            floatval = "low"
            runThreads(
                lines,
                floatval,
                webshare_ips,
                all_sessions,
                extended_scrape,
                Queues.listings_queue,
                Queues.csgofloat_queue,
            )
            time.sleep(60)


def runThreads(
    weapon_list: list,
    high_or_low: str,
    webshare_ips: list,
    all_sessions: list,
    extended_scrape: bool,
    listings_queue: queue.Queue,
    csgofloat_queue: queue.Queue,
):
    threads = []
    for line in weapon_list:
        m = NewMarketBot(
            high_or_low,
            str(line.rstrip()),
            webshare_ips,
            all_sessions,
            extended_scrape,
            listings_queue,
            csgofloat_queue,
        )
        t = threading.Thread(target=m.startBot)
        t.name = str(line).rstrip()
        t.daemon = True
        threads.append(t)
        all_threads.append(t)

    threadmonitor = ThreadMonitor(all_threads)
    threadmonitor_thread = threading.Thread(target=threadmonitor.list_running_threads)
    threadmonitor_thread.daemon = True
    threadmonitor_thread.name = "ActiveThreadsMonitor"
    all_threads.append(threadmonitor_thread)
    threadmonitor_thread.start()
    
    for thread in threads:
        thread.start()
        time.sleep(60)

    for thread in threads:
        thread.join()


if __name__ == "__main__":
    # Runs the scraper for all weapons
    logger.info("Start Program")
    startScraper(filename="list/tag_weapon_list.txt", bs_and_fn=True)
</pre></body></html>