- UID
- 89
- 积分
- 47
- 雷小钻
- 0
- 雷小币
- 900
- 贡献点数
- 17
- 注册时间
- 2023-12-25
- 在线时间
- 23 小时
- 最后登录
- 2024-11-19
|
发表于 2024-11-11 18:18:01
|
显示全部楼层
用处就是每周五大概9点10点运行一下更新下雷小伊脱机,这样就不用打开网页下载了。
代码
- const axios = require("axios");
- const fs = require('fs');
- const path = require('path');
- // const outputLocationPath = path.join(__dirname, '雷小伊.exe');
- const fileID = "b052mtlbg";
- const getT_K = async fileID => {
- const url = `https://lxy.lanzouj.com/${fileID}`;
- return await new Promise(async (rv, rj) => {
- const res = await axios.get(url, {
- timeout: 10000
- });
- const data = res.data;
- // console.log(data)
- const t = parseInt(data.match(/'(\d{10})'/)[0].match(/(\d{10})/)[0]);
- const k = data.match(/'([a-z0-9]{32})'/)[0].match(/([a-z0-9]{32})/)[0];
- rv({
- t,
- k
- });
- });
- };
- (async function () {
- const { t, k } = await getT_K(fileID);
- console.log({ t, k });
- const url = "https://lxy.lanzouj.com/filemoreajax.php?file=8948676";
- const formData = {
- lx: 2,
- fid: 8948676,
- uid: 3675175,
- pg: 1,
- rep: 0,
- t,
- k,
- up: 1,
- vip: 0,
- webfoldersign: ""
- };
- const response = await axios.post(url, formData, {
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- Origin: "https://lxy.lanzouj.com",
- Referer: "https://lxy.lanzouj.com/b052mtlbg",
- Host: "lxy.lanzouj.com"
- }
- });
- const data = response.data;
- const id_data = data.text.find(item => item.name_all.startsWith("雷小伊脱机日常"));
- const id = id_data ? id_data.id : null;
- console.log(id, id_data, `https://lxy.lanzouj.com/${id}`);
- const file_page_res = await axios.get(`https://lxy.lanzouj.com/${id}`);
- const install_ifr_url = `https://lxy.lanzouj.com${file_page_res.data.match(/<iframe[^>]*class="ifr2"[^>]*src="([^"]*)"/)[1]}`;
- console.log(`https://lxy.lanzouj.com${file_page_res.data.match(/<iframe[^>]*class="ifr2"[^>]*src="([^"]*)"/)[1]}`);
- const install_ifr_res = await axios.get(install_ifr_url);
- const str = install_ifr_res.data;
- const websignkey = str.match(/aihidcms\s*=\s*'([^']+)'/)[1];
- const ajaxdataMatch = str.match(/ajaxdata\s*=\s*'([^']+)'/);
- const dataSignMatch = str.match(/data\s*:\s*{[^}]*'sign'\s*:\s*'([^']+)'/);
- const urlMatch = str.match(/url\s*:\s*'([^']+)'/);
- const ajaxdata = ajaxdataMatch ? ajaxdataMatch[1] : null;
- const dataSign = dataSignMatch ? dataSignMatch[1] : null;
- const ajaxUrl = urlMatch ? urlMatch[1] : null;
- console.log("ajaxdata:", ajaxdata);
- console.log("data sign:", dataSign);
- console.log("ajax url:", ajaxUrl);
- console.log("websignkey: ", websignkey);
- const getDownloadUrl = await axios.post(`https://lxy.lanzouj.com${ajaxUrl}`, {
- action: "downprocess",
- signs: ajaxdata,
- sign: dataSign,
- websign: "",
- websignkey,
- ves: 1,
- kd: 1
- }, {
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- Origin: "https://lxy.lanzouj.com",
- Referer: "https://lxy.lanzouj.com/b052mtlbg",
- Host: "lxy.lanzouj.com"
- }
- });
- console.log(`https://lxy.lanzouj.com${ajaxUrl}`, getDownloadUrl.data);
- const fileUrl = `${getDownloadUrl.data['dom']}/file/${getDownloadUrl.data['url']}`
- console.log(fileUrl)
- const headers = {
- "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
- "sec-ch-ua": ""Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122"",
- "sec-ch-ua-mobile": "?0",
- "sec-ch-ua-platform": ""Windows"",
- "sec-fetch-dest": "document",
- "sec-fetch-mode": "navigate",
- "sec-fetch-site": "none",
- "sec-fetch-user": "?1",
- "upgrade-insecure-requests": "1",
- "cookie": "down_ip=1"
- };
- axios.interceptors.response.use(response => {
- return response;
- }, error => {
- if (error.response && error.response.status === 302) {
- const redirectUrl = error.response.headers.location;
- console.log('重定向链接:', redirectUrl);
- return axios.get(redirectUrl, { responseType: 'arraybuffer' });
- }
- return Promise.reject(error);
- });
- axios.get(fileUrl, { headers, maxRedirects: 0, responseType: 'arraybuffer' })
- .then(response => {
- console.log('最终请求的URL:', response.request.res.responseUrl);
- fs.writeFile('./test1.exe', response.data, (err) => {
- if (err) {
- console.error('写入文件时出错:', err);
- } else {
- console.log('文件已成功保存为 test1.exe');
- }
- });
- })
- .catch(error => {
- console.error('请求失败:', error.message);
- });
- })();
复制代码 下载:
https://mspring.lanzouo.com/iLvEc2etimmd
密码:7058 |
|