javascript-snippet
dramabox
dramabox woi
Lines: 28Chars: 805Size: 0.79 KB
javascript-snippet
1import axios from 'axios'
2async function dramaboxsearch(q){
3 try{
4 const r = await axios.get(`https://www.dramabox.com/search?searchValue=${encodeURIComponent(q)}`)
5
6 const json = JSON.parse(
7 r.data.match(/<script id="__NEXT_DATA__"[^>]*>([\s\S]*?)<\/script>/)[1]
8 )
9 const list = json.props.pageProps.bookList || []
10 return {
11 query: q,
12 total: list.length,
13 results: list.map(v => ({
14 id: v.bookId,
15 title: v.bookName,
16 episodes: v.totalChapterNum,
17 description: v.introduction,
18 cover: v.coverCutWap || v.coverWap,
19 play_url: `https://www.dramabox.com/video/${v.bookId}_${v.bookNameEn}/${v.chapterId}_Episode-1`
20 }))
21 }
22
23 }catch(e){
24 return { status:'eror', msg: e.message }
25 }
26}
27
28export default dramaboxsearch