Skip to content

Instantly share code, notes, and snippets.

@danielwpz
Created August 28, 2019 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielwpz/01f1631c77b7cbf089b92734bd38b10b to your computer and use it in GitHub Desktop.
Save danielwpz/01f1631c77b7cbf089b92734bd38b10b to your computer and use it in GitHub Desktop.
const axios = require('axios')
const findDup = require('array-find-duplicates')
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
}
async function run () {
let from = 0
const size = 50
let allProducts = []
const seed = getRandomInt(0, 10000)
while (from < 1000) {
const results = await axios.get(`https://api.heishiapp.com/search/v1/products/explore?seed=${seed}&from=${from}&size=${size}`)
const products = results.data
console.log(`Got ${products.length} products`)
allProducts = allProducts.concat(products)
from += size
}
productIds = allProducts.map(p => p.id)
console.log('total items', productIds.length)
console.log('dups:')
console.log(findDup(productIds))
}
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment