Skip to content

Instantly share code, notes, and snippets.

@fsjuhl
Last active July 7, 2019 00:38
Show Gist options
  • Save fsjuhl/7cd74bd27812df81af68e91faf19d60f to your computer and use it in GitHub Desktop.
Save fsjuhl/7cd74bd27812df81af68e91faf19d60f to your computer and use it in GitHub Desktop.
To run script: Get cookie (_cfduid) and set your user agent. Then do "npm i axios cheerio" and then "node botbroker.js"
BotBroker analysis:
Total sales: 1542
Total sales amount: $1,136,164.00
Average sale amount: $737.00
Total fees (buyer & seller): $147,701.00
Fees to Stripe: $34,085.00 (Actual: $33,411.60)
Fees to bot companies: $56,808.00
Fees to BotBroker: $56,808.00
AMNotify analysis:
Sales: 0
Lowest sale: $∞
Highest sale: -$∞
Average sale: NaN
Total: $0.00
Fees earned by bot company: $0.00
Balko analysis:
Sales: 131
Lowest sale: $901.00
Highest sale: $2,700.00
Average sale: $1,757.00
Total: $230,133.00
Fees earned by bot company: $11,507.00
Cyber AIO analysis:
Sales: 90
Lowest sale: $2,700.00
Highest sale: $5,400.00
Average sale: $3,646.00
Total: $328,156.00
Fees earned by bot company: $16,408.00
Dashe analysis:
Sales: 602
Lowest sale: $11.00
Highest sale: $1,000.00
Average sale: $400.00
Total: $240,545.00
Fees earned by bot company: $12,027.00
Ghost Phantom analysis:
Sales: 123
Lowest sale: $69.00
Highest sale: $2,500.00
Average sale: $968.00
Total: $119,060.00
Fees earned by bot company: $5,953.00
Ghost SNKRS analysis:
Sales: 236
Lowest sale: $163.00
Highest sale: $440.00
Average sale: $339.00
Total: $80,084.00
Fees earned by bot company: $4,004.00
Hastey analysis:
Sales: 76
Lowest sale: $60.00
Highest sale: $165.00
Average sale: $92.00
Total: $7,010.00
Fees earned by bot company: $351.00
Project Destroyer analysis:
Sales: 186
Lowest sale: $20.00
Highest sale: $850.00
Average sale: $502.00
Total: $93,367.00
Fees earned by bot company: $4,668.00
Sneakercopter analysis:
Sales: 63
Lowest sale: $11.00
Highest sale: $750.00
Average sale: $493.00
Total: $31,033.00
Fees earned by bot company: $1,552.00
Splashforce analysis:
Sales: 35
Lowest sale: $20.00
Highest sale: $310.00
Average sale: $194.00
Total: $6,776.00
Fees earned by bot company: $339.00
const axios = require("axios")
const cheerio = require("cheerio")
const cookie = "" // Replace with your cookie
const useragent = "" // Replace with your user agent
async function getSales(bot, page = 1, sales = []) {
try {
const req = await axios.get(`https://botbroker.io/bots/${bot.id}/sales/more?bot_sales_page=${page}&_=${+ new Date()}`, {
headers: {
"x-requested-with": "XMLHttpRequest",
cookie,
"user-agent": useragent
}
})
.then(res => unescape(res.data))
const $ = cheerio.load(
"<table><tbody>" +
req.split(`$("#sales-table-body").append("`)[1].split(`");`)[0] +
"</tbody></table>"
)
sales = sales.concat(
Array.from($("tr td:first-child small"))
.map(el =>
Number($(el).text()
.split("\\n")[1]
.split("\\n")[0]
.trim()
.replace("$", ""))
)
)
if (!req.includes(`$("#load-more-sales").fadeOut();`)) {
return await getSales(bot, page + 1, sales)
} else {
return { ...bot, sales }
}
} catch (e) {
return { ...bot, sales: [] }
}
}
async function getBotId(bot) {
const $ = await axios.get(`https://botbroker.io/bots/${bot.urlName}`, {
headers: {
cookie,
"user-agent": useragent
}
})
.then(res => res.data)
.then(html => cheerio.load(html))
const id = $("#view-all-sales").attr("data-id")
return { ...bot, id }
}
async function getBots() {
const $ = await axios.get(`https://botbroker.io/bots?_=${+ new Date()}`, {
headers: {
cookie,
"user-agent": useragent
}
})
.then(res => res.data)
.then(html => cheerio.load(html))
const bots = Array.from($("#pills-all div.col-md-4.mt-3")).map(el => {
const name = $(el).find(".font-weight-bold.text-dark").text().trim()
const price = Number($(el).find(".font-weight-bold.text-secondary").text().trim().replace("$", ""))
const urlName = $(el).find("[href^='/bots/']").first().attr("href").replace("/bots/", "")
const image = $(el).find(".bot-image").attr("src")
return { name, price, urlName, image }
})
return bots
}
async function main() {
let bots = await getBots()
bots = await Promise.all(bots.map(bot => getBotId(bot)))
bots = await Promise.all(bots.map(bot => getSales(bot)))
processData(bots)
}
function processData(raw) {
const formatter = new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD",
})
let allSales = 0,
amountOfSales = 0
raw.forEach(bot => {
const totalSales = bot.sales.reduce((tally, sale) => tally + sale, 0)
allSales += totalSales
amountOfSales += bot.sales.length
const lowestSale = Math.min(...bot.sales)
const highestSale = Math.max(...bot.sales)
const averageSale = Math.round(totalSales / bot.sales.length)
const output =
`${bot.name} analysis:\n` +
`Sales: ${bot.sales.length}\n` +
`Lowest sale: ${formatter.format(lowestSale)}\n` +
`Highest sale: ${formatter.format(highestSale)}\n` +
`Average sale: ${formatter.format(averageSale)}\n` +
`Total: ${formatter.format(totalSales)}\n` +
`Fees earned by bot company: ${formatter.format(Math.round(totalSales / 100 * 5))}\n`
console.log(output)
})
const totalOutput =
`BotBroker analysis:\n` +
`Total sales: ${amountOfSales}\n` +
`Total sales amount: ${formatter.format(allSales)}\n` +
`Average sale amount: ${formatter.format(Math.round(allSales / amountOfSales))}\n` +
`Total fees (buyer & seller): ${formatter.format(Math.round(allSales / 100 * 13))}\n` +
`Fees to Stripe: ${formatter.format(Math.round(allSales / 100 * 3))} (Actual: ${formatter.format(Math.round(allSales / 100 * 2.9) + amountOfSales * 0.3)})\n` +
`Fees to bot companies: ${formatter.format(Math.round(allSales / 100 * 5))}\n` +
`Fees to BotBroker: ${formatter.format(Math.round(allSales / 100 * 5))}\n`
console.log(totalOutput)
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment