根据番号搜索电影
(code: string)
| 97 | const { data } = await axios.get<string>(url, { |
| 98 | headers: { |
| 99 | accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", |
| 100 | "accept-language": "zh-CN,zh;q=0.9", |
| 101 | "user-agent": "Mozilla/5.0 TeleBoxBot", |
| 102 | }, |
| 103 | timeout: 15000, |
| 104 | }); |
| 105 | |
| 106 | // 解析 HTML 响应 |
| 107 | const $ = cheerio.load(data); |
| 108 | |
| 109 | // 提取搜索结果 |
| 110 | return $(".movie-list .item").toArray().map((el) => { |
| 111 | const $a = $(el).find("a"); |
| 112 | const title = $a.find(".video-title").text().trim(); |
| 113 | const codeInTitle = (/([A-Za-z]+-\d+)/.exec(title)?.[1] || "") |
| 114 | .replace(/\s+/g, "") |
| 115 | .toUpperCase(); |
| 116 | return { |
| 117 | code: codeInTitle, |
| 118 | link: "https://javdb.com" + ($a.attr("href") || ""), |
| 119 | title, |
| 120 | thumb: $a.find(".cover img").attr("src") || "", |
| 121 | score: $a.find(".score span.value").text().trim() || "", |
| 122 | meta: $a.find(".meta").text().trim() || "", |
| 123 | }; |
| 124 | }); |
| 125 | } |
| 126 | |
| 127 | /** 获取电影详细信息 */ |
| 128 | async function fetchDetail(url: string): Promise<MovieDetail> { |
| 129 | // 请求详情页面 |
| 130 | const { data: html } = await axios.get<string>(url, { |
| 131 | headers: { |
| 132 | accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", |
| 133 | "accept-language": "zh-CN,zh;q=0.9", |
| 134 | "user-agent": "Mozilla/5.0 TeleBoxBot", |
| 135 | }, |