import { parse } from "https://deno.land/std@0.136.0/flags/mod.ts"; import { DOMParser, Element } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts"; async function getThumUrl(url: string): Promise { const res = await fetch(url); const doc = new DOMParser().parseFromString(await res.text(), "text/html"); if (doc == null) { throw new Error("document not found"); } const node = doc.querySelectorAll('meta[property="og:image"]')[0] as Element; const title = doc.querySelectorAll('head > title')[0] as Element; console.log(title.textContent); const thumbUrl = node.getAttribute("content"); if (thumbUrl == null) { throw new Error("document not found"); } console.log(thumbUrl); return thumbUrl; } const parsedArgs = parse(Deno.args); getThumUrl(parsedArgs.url);