获取英文名

This commit is contained in:
2023-07-11 20:52:30 +08:00
parent 3adfce7781
commit ce408dce8b
4 changed files with 86 additions and 17 deletions

View File

@@ -1,12 +1,14 @@
const Router = require("koa-router")
const { serach, gen_douban } = require("../util/ptgen")
const axios = require("axios")
const cheerio = require("cheerio"); // HTML页面解析
const router = new Router({
prefix:"/videoInfo"
prefix: "/videoInfo"
})
router.get("/search",async (ctx)=>{
router.get("/search", async (ctx) => {
let name = ctx.query.name
ctx.body = await serach(name)
})
@@ -17,15 +19,15 @@ router.get("/search",async (ctx)=>{
// ctx.body = info
// })
router.get("/searchVideo",async (ctx)=>{
router.get("/searchVideo", async (ctx) => {
let name = ctx.query.name
ctx.body = await serach(name)
})
router.get("/getVideoInfo",async (ctx)=>{
router.get("/getVideoInfo", async (ctx) => {
let id = ctx.query.id
if(!id){
if (!id) {
ctx.body = "请传递id"
return
}
@@ -33,4 +35,22 @@ router.get("/getVideoInfo",async (ctx)=>{
})
router.post("/addSubscribe", async (ctx) => {
// console.log(ctx.request.body)
let data = ctx.request.body
})
router.get("/getImdbName", async (ctx) => {
let res = await axios.get(ctx.query.url, {
proxy: false,
headers:{
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67"
}
})
// console.log(res.data)
let $ = cheerio.load(res.data)
ctx.body = $("h1").text()
})
module.exports = router