Untitled
unknown
typescript
2 years ago
781 B
4
Indexable
const sourceScraper = async (url: string) => { const {data} = await axios.get(url); const $ = cheerio.load(data); const sources = $(".keremiya_part a") .map((i, el) => { return {url: $(el).attr("href") as string, text: $(el).text()}; }) .toArray(); return { current: { url: url, text: $(".keremiya_part > span").text(), }, alternatives: sources, }; }; const videoScraper = async (source: Source) => { const {data} = await axios.get(source.url); const $ = cheerio.load(data); const video = $("iframe").attr("src"); if (!video) throw new Error("Video not found"); if (video.startsWith("https") || video.startsWith("http")) return video; const videoUrl = "https:" + video; return videoUrl; };
Editor is loading...