示例#1
0
    browser.set_page_load_timeout(5)
    logger.info('Started Chrome')
    return browser


if __name__ == '__main__':
    # Launch selenium
    try:
        b = launch()
        b.get(amazonBot.ITEM_URL)
    except Exception as inst:
        logger.error('Failed to open browser: {}'.format(format(inst)))

    # Item purchasing logic
    try:
        done = False
        while (not done):
            try:
                # Navigate to the item and buy if checks pass
                if amazonBot.purchase_item(b):
                    done = True
                    logger.info("Successfully purchased item")
            except Exception as e:
                logger.error('ERROR: {}'.format(e))
    finally:
        logger.info('Closing Chromium')
        try:
            b.close()
        except BaseException:
            pass
        logger.info('Closed Chromium')
示例#2
0
        exit()

    # Log in
    try:
        amazonBot.login(b, email, password)
    except Exception as e:
        logger.error('Error Could not login: {}'.format(e))
        exit()

    # Item purchasing logic
    try:
        done = False
        while (not done):
            try:
                # Navigate to the item and buy if checks pass
                done = amazonBot.purchase_item(b, url, LIMIT_VALUE,
                                               ACCEPT_SHOP)
                logger.info("Successfully purchased item")
            except BaseException:
                pass
            except Exception as e:
                logger.error('ERROR: {}'.format(e))
            time.sleep(DELAY)
    finally:
        logger.info('Closing Chromium')
        try:
            b.close()
        except BaseException:
            pass
        logger.info('Closed Chromium')