Skip to content

Instantly share code, notes, and snippets.

@esirK
Last active March 30, 2022 00:58
Show Gist options
  • Save esirK/9de68c26d305ba09508a3e0b820fc195 to your computer and use it in GitHub Desktop.
Save esirK/9de68c26d305ba09508a3e0b820fc195 to your computer and use it in GitHub Desktop.
const request = require('request');
const cheerio = require('cheerio');
const url = 'https://browser.geekbench.com/';
async function getData(url) {
let requests = [];
return new Promise((resolve, reject) => {
request(`${url}/processor-benchmarks`, function (error, response, body) {
const $ = cheerio.load(body);
$('td a').each(function (i, elem) {
requests.push(url + elem.attribs.href);
}).text();
resolve(requests);
});
});
}
async function getSpecs(url) {
return new Promise((resolve, reject) => {
request(url, function (error, response, body) {
let obj;
const $ = cheerio.load(body);
let score = $('.score').text().slice(0, 9);
const scscore = score.slice(0, 4);
const mcscore = score.slice(4);
let tabledata = $('.system-table').text();
tabledata = tabledata.split('\n').filter(item => item);
const processor = tabledata[1];
const freq = tabledata[3];
const maxfreq = tabledata[5];
const cores = tabledata[7];
const threads = tabledata[9];
const tdp = tabledata[11];
const codename = tabledata[13];
const package = tabledata[15];
obj = { mcscore, scscore, processor, freq, maxfreq, cores, threads, tdp, codename, package };
resolve(obj);
});
});
}
async function main() {
let data = await getData(url);
let specs = [];
data = data.slice(0, 2); // Due to the fact that the website has a limit of the number of requests it can make, we are only going to make 2 requests.
console.log(data);
for (const item of data) {
specs.push(await getSpecs(item));
}
console.log(specs);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment