Created
August 28, 2019 13:29
-
-
Save danielwpz/01f1631c77b7cbf089b92734bd38b10b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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