import { DOMParser, Element } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts"; // https://www.nicovideo.jp/watch/sm37231246 export 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 thumbUrl = node.getAttribute("content"); if (thumbUrl == null) { throw new Error("document not found"); } console.log(thumbUrl); return thumbUrl; }