获取搜索列表
This commit is contained in:
43
util/reptileutil.js
Normal file
43
util/reptileutil.js
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user