Created
December 8, 2019 12:29
-
-
Save nullbytepl/2c4dc2d6ea9c11cd0578cbb7c940eaef 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
function aliDeals(minDiscount = 40, n = 0){ | |
let isOk = true; | |
fetch(`https://gpsfront.aliexpress.com/getRecommendingResults.do?widgetId=8202070&limit=20&imageSize=350x350¤cy=PLN&site=glo&locale=en_US&offset=${n}&postback=7751d6e7-7625-4970-b7ed-45e5dab69747&callback=jQuery213004515725211685884_1575805893592&_=1575805893599`, {"credentials":"include","headers":{"accept":"*/*","accept-language":"en-US,en;q=0.9,pl-PL;q=0.8,pl;q=0.7","sec-fetch-mode":"no-cors","sec-fetch-site":"same-site"},"referrer":"https://sale.aliexpress.com/__pc/tItp3pV11D.htm?aff_platform=promotion&cpt=1575805870131&sk=nHz3rGy0&aff_trace_key=079a095888a74e63b76f15dd072ccb73-1575805870131-07628-nHz3rGy0&terminal_id=cc80c22371df499cbb0af0e12e370f71","referrerPolicy":"no-referrer-when-downgrade","body":null,"method":"GET","mode":"cors"}).then(res => res.text()).then(res=> res.replace(/\/\*\*\/jQuery[0-9_]{35}\(/, '')).then(res => res.replace(');', '')).then((res)=>{ | |
let result = JSON.parse(res); | |
if (result.results.length == 0) { | |
isOk = false; | |
} | |
result.results.forEach((el)=>{ | |
el.oriMinPrice = Number(el.oriMinPrice.replace(' zł', '').replace(',', '.')); | |
el.minPrice = Number(el.minPrice.replace(' zł', '').replace(',', '.')); | |
el.percentOff = Math.floor((el.oriMinPrice-el.minPrice)/el.oriMinPrice*100, 2); | |
el.percentOff > minDiscount ? console.log(`Discount ${el.percentOff}% Price Now: ${el.minPrice/2}zł Title: ${el.productTitle} Link: ${el.productDetailUrl}`) : false; | |
}); | |
}).finally(()=>{ | |
isOk ? aliDeals(minDiscount, n+20) : console.log('Koniec; Umieram.'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment