Public
Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import Exa from "npm:exa-js";
const exaSecret = Deno.env.get("EXA_API_KEY");
const exa = new Exa(exaSecret);
const similarSites = async function(url: string) {
const results = await exa.findSimilar(url);
if (results.results) {
let elements = results.results.map((el) => {
return {
"score": el.score,
"url": el.url,
};
});
elements.sort((a, b) => b.score - a.score);
return elements;
}
else {
return [];
}
};
const sites = await similarSites("www.peterzakin.com");
console.log(sites);
export default similarSites;
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
July 19, 2024