47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
|
|
import cheerio from "cheerio"
|
|
import axios from "axios"
|
|
|
|
class Reptile {
|
|
// 初始化代理
|
|
constructor(proxy) {
|
|
if (proxy) {
|
|
axios.defaults.proxy = proxy
|
|
}
|
|
}
|
|
// 通过名字搜索
|
|
async find(name) {
|
|
let url = `https://dmhy.anoneko.com/topics/list?keyword=${name}`
|
|
url = encodeURI(url)
|
|
console.log(url)
|
|
const { data } = await axios.get(url)
|
|
const $ = cheerio.load(data)
|
|
let list = []
|
|
$("#topic_list tr").map((index, el) => {
|
|
let name = $(el).find(".title > a").text()
|
|
let link = $(el).find(".download-arrow").attr("href")
|
|
let classify = $(el).find("td:eq(1)").find("a").text()
|
|
name = name.replace(/\n/g, "")
|
|
classify = classify.replace(/\n/g, "")
|
|
const info = {
|
|
name,
|
|
link,
|
|
classify
|
|
}
|
|
list.push(info)
|
|
})
|
|
console.log(JSON.stringify(list))
|
|
}
|
|
// 获取[]中间的内容 目前通过这个获取第几集
|
|
async getepisode(name) {
|
|
// let re = /\[.*?\]/g
|
|
let episode = name.match( /(?<=\[).*?(?=\])/g)
|
|
console.log(episode)
|
|
// var myRe = /d(b+)d/g;
|
|
// var myArray = myRe.exec("cdbbdbsbz");
|
|
// console.log(myArray.length)
|
|
}
|
|
}
|
|
|
|
export default Reptile
|