33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
const axios = require('axios');
|
|
const config = require("./config");
|
|
const iconv = require('iconv-lite');
|
|
|
|
class http {
|
|
constructor() {
|
|
this.http = axios.create({
|
|
baseURL: config.url,
|
|
timeout: 100000,
|
|
headers: {
|
|
"Cookie": "__yjs_duid=1_54d7d9761ff38fd500742b8c976378851637137358248; xygkqecookieclassrecord=%2C1%2C; Hm_lvt_14b14198b6e26157b7eba06b390ab763=1637137357,1637138134,1637138153,1637138272; xygkqecookieinforecord=%2C7-24028%2C7-24022%2C1-1%2C19-23857%2C11-23937%2C12-24000%2C; Hm_lpvt_14b14198b6e26157b7eba06b390ab763=1637144818",
|
|
"Host": "www.netbian.com",
|
|
"Referer": "http://www.netbian.com/index.htm",
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
|
|
}
|
|
});
|
|
}
|
|
|
|
async get(params) {
|
|
var res = (await this.http.get(params.url, {
|
|
params: params.data,
|
|
responseType: params.type ? "arraybuffer" : "stream"
|
|
})).data;
|
|
if (params.type == "1") {
|
|
return iconv.decode(res,'gbk');
|
|
} else {
|
|
return res;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
module.exports = new http(); |