Created
March 19, 2025 22:23
-
-
Save Heliodex/a671a0ca778b49b247c818e30a480a2a to your computer and use it in GitHub Desktop.
Script I used to search all laptops on CeX through search.webuy.com
This file contains hidden or 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
import data1 from "./250-350.json" | |
import data2 from "./350-400.json" | |
import data3 from "./400-500.json" | |
import data4 from "./500-550.json" | |
const hits1 = data1.results[0].hits | |
const hits2 = data2.results[0].hits | |
const hits3 = data3.results[0].hits | |
const hits4 = data4.results[0].hits | |
const ahits = [ | |
...hits1.map(hit => ({ | |
set: 1, | |
id: hit.objectID, | |
name: hit._highlightResult.boxName.value, | |
})), | |
...hits2.map(hit => ({ | |
set: 2, | |
id: hit.objectID, | |
name: hit._highlightResult.boxName.value, | |
})), | |
...hits3.map(hit => ({ | |
set: 3, | |
id: hit.objectID, | |
name: hit._highlightResult.boxName.value, | |
})), | |
...hits4.map(hit => ({ | |
set: 4, | |
id: hit.objectID, | |
name: hit._highlightResult.boxName.value, | |
})), | |
] | |
// .sort((a, b) => { | |
// return Math.random() - 0.5 | |
// }) | |
const hitsf = [] | |
for (let i = 0; i < ahits.length; i++) { | |
const hit = ahits[i] | |
const nameparts = hit.name.split("/") | |
// props may or may not exist ykyk | |
const [modelNum, processor, ram, ssd, ...rest] = nameparts | |
// find the rest that ends in " | |
const screenSize = rest.find(part => part.includes('"')) | |
if (screenSize) rest.splice(rest.indexOf(screenSize), 1) | |
// find the last item (A, B, C) | |
const grade = hit.id.at(-1) | |
if (!grade) throw new Error("No grade found") | |
if (["A", "B", "C"].includes(rest.at(-1) || "")) rest.pop() | |
// remove the W11/W10 from rest | |
const oses = ["W10", "W11"] | |
const os = rest.find(part => oses.includes(part)) | |
if (os) rest.splice(rest.indexOf(os), 1) | |
// ok actual time | |
if (modelNum.toLowerCase().startsWith("hp")) continue | |
if (grade === "C") continue | |
if ( | |
ssd.toLowerCase().includes("emmc") || | |
ssd.toLowerCase().includes("hdd") || | |
ssd.startsWith("128") | |
) | |
continue | |
if ( | |
ram.startsWith("2GB") || | |
ram.startsWith("4GB") || | |
ram.startsWith("6GB") || | |
ram.startsWith("8GB") || | |
ram.startsWith("12GB") || | |
false | |
) | |
continue | |
if ( screenSize && !screenSize.startsWith("14")) continue | |
const p = processor.toLowerCase().trim().replace("ryz ", "ryzen ") | |
if ( | |
// celeron | |
p.startsWith("n") || | |
// xeon | |
p.startsWith("e3") || | |
// old i5s | |
p.startsWith("i5") || | |
p.startsWith("ultra 5") || | |
// old i7s | |
p.startsWith("i7-4") || | |
p.startsWith("i7-5") || | |
p.startsWith("i7-6") || | |
p.startsWith("i7-7") || | |
p.startsWith("i7-8") || | |
p.startsWith("i7- 8") || | |
p.startsWith("i7-9") || | |
p.startsWith("i7-10") || | |
p.startsWith("i7-11") || // i didnt want to do this but... q3 2020 | |
p.startsWith("i7-12") || | |
// p.startsWith("i7 13") || | |
// p.startsWith("i7-13") || | |
p.startsWith("i9-9") || | |
// zen 2 | |
p.startsWith("ryzen 5 pro 3") || | |
p.startsWith("ryzen 5 pro 4") || | |
// p.startsWith("ryzen 5 pro 5") || | |
p.startsWith("ryzen 7 pro 3") || | |
p.startsWith("ryzen 7 pro 4") || | |
// p.startsWith("ryzen 7 pro 5") || | |
p.startsWith("ryzen 5 2") || | |
p.startsWith("ryzen 5 3") || | |
p.startsWith("ryzen 5 4") || | |
// p.startsWith("ryzen 5 5") || | |
// p.startsWith("ryzen 5 6") || | |
p.startsWith("ryzen 7 2") || | |
p.startsWith("ryzen 7 3") || | |
p.startsWith("ryzen 7 4") || | |
// p.startsWith("ryzen 7 5") || | |
false | |
) | |
continue | |
if (modelNum.startsWith("Lenovo V15")) continue // bruh | |
// if (!p.startsWith("Ry")) continue | |
console.log(`${i + 1}. https://uk.webuy.com/product-detail?id=${hit.id}`) | |
console.log(` Model: ${modelNum}`) | |
console.log(` Processor: ${processor}`) | |
console.log(` RAM: ${ram}`) | |
console.log(` Storage: ${ssd}`) | |
if (screenSize) console.log(` Screen: ${screenSize}`) | |
if (rest.length) console.log(rest) | |
hitsf.push(hit) | |
} | |
console.log(hitsf.length) // narrowed down from 1000 to 6 | |
const namecounts: { [name: string]: number } = {} | |
for (const hit of hitsf) { | |
const name = hit.name.split(" ")[0].toLowerCase() | |
if (!namecounts[name]) namecounts[name] = 0 | |
namecounts[name]++ | |
} | |
console.log(namecounts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment