Код: Выделить всё
import crypto from 'node:crypto'
import { getSuffPref } from './getSuffPref.js';
import { canonize } from './canonize.js';
function getHash64(pref) {
let hash = crypto
.createHash('sha256')
.update(pref, 'utf-8')
.digest();
return hash.subarray(0, 4).toString('base64');
}
let urls = getSuffPref(canonize('https://dgomeq.loveiswe.com/?utm_source=da57dc555e50572d&s1=196580&s2=2016932&j6=1&s3=64016&click_id=467a4fdaceb2561f8993991750c25be7&ban=other&j1=1&j8=1'))
let finalArr = urls.map(getHash64)
async function checkSiteSafe(hashList) {
let url = new URL('https://safebrowsing.googleapis.com/v5/hashes:search');
url.searchParams.set('key', 'key');
for (let pref of hashList) {
url.searchParams.append('hashPrefixes', pref);
}
let response = await fetch(url.toString(),
{
'method': 'GET',
});
return [response.status, await response.text()]
}
checkSiteSafe(finalArr).then(result => console.log(result))
Подробнее здесь: https://stackoverflow.com/questions/793 ... rowsing-v5