自动分批导入域名到爱快的域名分流

首先下载23988个域名

https://raw.githubusercontent.com/Loyalsoldier/cn-blocked-domain/release/domains.txt

然后编写node代码,修改爱快的IP和Cookie

const fs = require('fs');
const readline = require('readline');

async function processFile(filePath) {
  const fileStream = fs.createReadStream(filePath);
  const rl = readline.createInterface({
    input: fileStream,
    crlfDelay: Infinity
  });

  let lines = [];

  for await (const line of rl) {
    lines.push(line);

    if (lines.length === 1000) {
      await processLines(lines); // Process the current 1000 lines
      lines = []; // Reset the array for the next batch
    }
  }

  // Process any remaining lines that are less than 1000
  if (lines.length > 0) {
    await processLines(lines);
  }
}

async function processLines(lines) {
  // Replace this with your actual processing logic
  console.log(`Processing ${lines.length} lines`);
  await stream_domain_add(lines.join(','));
  await new Promise(resolve => setTimeout(resolve, 100)); // Simulating async operation
}

// Call the function with the file path
processFile(__dirname + '/domains.txt')
  .then(() => console.log('File processed successfully'))
  .catch(err => console.error('Error processing file:', err));

async function stream_domain_add(domain) {
  const body = {"func_name":"stream_domain","action":"add","param":{"interface":"vwan_sb1","src_addr":"","domain":domain,"comment":"","week":"1234567","time":"00:00-23:59","enabled":"yes"}};
  const res = await fetch(`http://10.86.11.1/Action/call`, {
    "headers": {
      "accept": "application/json, text/plain, */*",
      "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
      "cache-control": "no-cache",
      "content-type": "application/json;charset=UTF-8",
      "pragma": "no-cache",
      "cookie": '',
      "Referer": `http://10.86.11.1/`,
      "Referrer-Policy": "strict-origin-when-cross-origin"
    },
    "body": JSON.stringify(body),
    "method": "POST"
  });
  console.log(await res.text());
}
posted on 2025-01-07 01:45  项希盛  阅读(90)  评论(0)    收藏  举报