コード例 #1
0
def inStock(s_id: str, price: float) -> bool:
    url = 'https://www.newegg.com/product/api/ProductRealtime?ItemNumber=' + s_id
    try:
        r = requests.get(url)
    except:
        colors.printFail('Failed to make request to instock API, trying again...')
        return inStock(s_id, price)
    if r.status_code == 200:
        try:
            j = r.json()
            inStock = j['MainItem']['Instock']
            acceptPrice = j['MainItem']['FinalPrice'] <= price
            if inStock and acceptPrice:
                colors.printSuccess('ITEM IN STOCK FOR GOOD PRICE!!!')
            elif inStock and not acceptPrice:
                colors.printFail('Item in stock, price too high...')
            else:
                colors.printInfo('Item not in stock...')
            return inStock and acceptPrice
        except:
            colors.printFail('Invalid response, IP block?')
            return False
    else:
        colors.printFail('Unsuccessful request made, IP block?')
        return False
コード例 #2
0
def saveCookies(sel):
    d = {}
    for c in sel.get_cookies():
        d[c['name']] = c['value']
    j = json.dumps(d)
    f = open("cookies.json", "w")
    f.write(j)
    f.close()
    colors.printSuccess('saved cookies!')
コード例 #3
0
def testCookies() -> bool:
    cookies = loadCookies()
    config = configparser.ConfigParser()
    config.read('config.ini')
    product_id = config['ALWAYSWORKS']['primaryId']
    secondary_product_id = config['ALWAYSWORKS']['secondaryId']
    cvv = config['CREDENTIALS']['cvv']
    colors.printInfo('Running in always successful mode (no buying)')
    addToCart(product_id, cookies)
    transactionComplete = checkout(config, cookies, product_id, secondary_product_id, cvv, True)
    if not transactionComplete:
        colors.printFail('Need to update cookies!')
    else:
        colors.printSuccess('Cookies working...')
    return transactionComplete
コード例 #4
0
def switchVPN(vpn_id: str, username: str, password: str) -> None:
    formerIP = getCurrIp()
    colors.printInfo('Swapping IP address...')
    killVPN()
    newConfigFile = getConfigFileName(vpn_id)
    res = os.system('./vpnConnector.sh ' + newConfigFile + ' ' + username +
                    ' ' + password)
    if res != 0:
        colors.printFail('Failed to connect to VPN. Trying again...')
        switchVPN(vpn_id, username, password)
    else:
        time.sleep(10)
    if formerIP == getCurrIp():
        colors.printFail('Unsuccessful swap...trying again in 5 seconds')
        time.sleep(5)
        switchVPN(vpn_id, username, password)
    else:
        colors.printSuccess('Successful swap of IP address...')
コード例 #5
0
def checkout(config: dict, cookies: dict, p_id: str, s_id: str, cvv: str, test: bool) -> bool:
    sessionId = genSessionID(cookies, s_id)
    url = 'https://secure.newegg.com/shop/checkout?sessionId=' + sessionId
    transactionNumber = getTransactionNumber(cookies, sessionId)
    if transactionNumber == None:
        return False
    if submitCardInfo(transactionNumber, cookies, cvv, sessionId, transactionNumber):
        if validateAddress(config, cookies, sessionId, transactionNumber):
            if not test:
                if submit_order(cookies, sessionId):
                    colors.printSuccess("Success! Check your inbox")
                    return True
            else:
                colors.printInfo('session_id: ' + sessionId)
                colors.printInfo('transaction_number: ' + transactionNumber)
                return True
        else:
            return checkout(config, cookies, p_id, s_id, cvv)

    else:
        colors.printFail("Couldnt check out, retrying")
        return checkout(config, cookies, p_id, s_id)
    return True