Coder Social home page Coder Social logo

shamvoke / sneakerbot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from samc621/sneakerbot

0.0 0.0 0.0 412 KB

All-in-one bot, with auto captcha-solving and proxy management, using Node.js and Puppeteer.

JavaScript 96.86% Shell 0.74% Dockerfile 2.41%

sneakerbot's Introduction

SneakerBot

This bot uses Node.js and Puppeteer to automate the checkout on various sneaker websites. It currently works on:

  1. Footsites (footlocker.com, footaction.com, eastbay.com, champssports.com)
  2. Shopify sites (e.g. BdgaStore, Concepts, Kith, etc.)
  3. Demandware sites (e.g. Adidas)
  4. Nike.com
  5. Supreme

Prerequisites

Install the following on your machine:

  1. Node.js (comes with npm)
  2. PostgreSQL

Set up PostgreSQL

View the documentation for creating a user and database.

Configure environment variables

Make a copy of the .env.example file, replacing example with the name of your NODE_ENV e.g. local or development.

When you're ready, declare the environment name with:

$ export NODE_ENV=local

Optional: Configure credit cards

The .env file that you configure is set up for a single credit card.

However, if you want to specify multiple credit cards, populate credit-cards.json using the example from credit-cards-example.json.

If you prefer not to use this method, you can simply leave this JSON file as-is.

When starting a task, you can optionally specify the card you want to use via its friendlyName, otherwise the card from the .env file will be used.

Install the dependencies

$ npm install

Run the DB migrations

$ knex migrate:latest

Run the DB seeders

$ knex seed:run

Start the server

Tasks run parallelly using puppeteer-cluster.

Before starting up the server, define the number of concurrent tasks you plan to run:

$ export PARALLEL_TASKS=5

If you do not define this variable, it will default to 1.

You can of course run more tasks, but they will be queued to run in a first-in, first-out (FIFO) manner.

Keep in mind that tasks that do not result in checkoutComplete will remain idle (not terminate) so that you can open the browser and view the error(s).

If a task encounters a captcha that must be manually solved, it will also remain idle and await completion.

Each task uses its own browser, so it's also important to keep in mind the CPU constraints of your machine.

When you're ready, start the server with:

$ npm start

Optional: Using Docker / Docker Compose

This may be particularly useful for Linux users who have reported issues with Puppeteer and Chromium.

You will need to have Docker Compose and/or Docker installed to use this.

You will also need to make a copy of the .env.example file, replacing example with the name of your NODE_ENV e.g. docker.

A Docker image is available for the server code here. You can also build it yourself by running the following in the root directory:

$ docker build -t sneakerbot .

Then run it and specify the env file with:

docker run -p 5900:5900 -p 8000:8000 --env NODE_ENV=docker --env-file .env.docker sneakerbot (replace 8000 with whatever PORT you specified in .env.docker)

This Docker image is built from node:12 and uses xvfb with x11vnc to provide access to a GUI.

You can use vncviewer to connect to the VNC server running in the container.

You may also opt to run Postgres via Docker, in which case you can make use of the docker-compose.yml file. Simply run the following in the root directory:

$ docker-compose build

$ docker-compose up

API

For each API, view the docs and try the requests in Postman.

Starting a Task

You may start a task via POST /v1/tasks/:id/start or use the start-task.js script like:

$ TASK_ID=<TASK_ID> CARD_FRIENDLY_NAME=<CARD_FRIENDLY_NAME> node ./scripts/start-task.js

Captcha Solving

This bot enables manual and automatic (via 2Captcha) solving of captchas.

When creating a task, you can specify auto_solve_captcha (Boolean), however, this parameter is optional and defaults to true.

You must sign up for and fund a 2Captcha account, and then add your API_KEY_2CAPTCHA to the .env file in order to auto-solve captchas.

For manually-solving captchas, you will be given a 5-minute timeout after the email notification to check the browser and solve the captcha.

Motivation

As a teenager, I operated sneakerbots.us, where I sold sneakerbots like this in addition to early links and ATC services.

Fastforward several years, I decided to upgrade this all-in-one bot from Java + Selenium to Node.js + Puppeteer, which I enjoy more for bot projects.

I am open sourcing this repo now, since I no longer operate the business, but also because I am of the opinion that this software can rival any of the others out there that sell for hundreds of dollars.

Feel free to open a Pull Request to contribute to this proejct and help make it better! I will continue to support more websites and add more features as I can.

Also feel free to open an Issue or contact me via Telegram @samc621 if you have any trouble.

If you appreciate this, consider buying me a coffee.

sneakerbot's People

Contributors

samc621 avatar sritchie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.