use elysia instead of express
This commit is contained in:
14
src/common/getImgTitle.ts
Normal file
14
src/common/getImgTitle.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Legica } from "@models";
|
||||
import axios from "axios";
|
||||
import cheerio from "cheerio";
|
||||
|
||||
export async function getImgTitle(href: string): Promise<Legica> {
|
||||
const response = await axios.get(href);
|
||||
const html = response.data;
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
const title = $(".Article-inner > h1").text();
|
||||
const { src: img } = $(".Article-media > img").attr() || {};
|
||||
|
||||
return { title, img };
|
||||
}
|
||||
Reference in New Issue
Block a user