Answer the question
In order to leave comments, you need to log in
Why, after reading the file, the lines are displayed crookedly?
Hello. Please tell me what can I do in this case:
let proxyList = fs.readFileSync('proxy.txt', 'utf-8').split(" ").toString();
const targetProxy = proxyList.split(' ').map(el => el + '8080');
targetProxy has a hundred addresses, each on a new line - port 8080 is repeated on the last 2 times and that's it, if you use it like this:`${ip}:8080` то порт получается спереди и ip рандомно перемешивается
Answer the question
In order to leave comments, you need to log in
in the file proxy.txt
Moscow:
91.243.188.184
91.243.188.114
91.243.188.30
91.243.188.137
SPB:
109.120.128.178
109.120.128.179
109.120.128.180
New IP Moscow:
83.166.240.184
83.166.241.9
83.166.241.120
port: 7951
login/pas: In the account https://www.oplata.info/info/delivery.asp
const filedata = fs.readFileSync('proxy.txt', 'utf-8');
const proxyData = filedata.split(/\s*?\n+\s*/).reduce(
(acc, line)=>{
if( /\w+:$/.test(line)){
acc.location = line;
}else if( /port:\s*\d+/.test(line)){
acc.port = line.replace(/\D+/g,'');
}else if( /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/.test(line)){
acc.list.push({
ip: line,
location: acc.location
});
}
return acc;
},
{
list:[],
location: undefined,
port: undefined
}
);
const targetProxy = proxyData.list.map(item => item.ip + ':' + proxyData.port);
console.log(targetProxy)
// 91.243.188.184:7951
// 91.243.188.114:7951
// 91.243.188.30:7951
// 91.243.188.137:7951
// 109.120.128.178:7951
// 109.120.128.179:7951
// 109.120.128.180:7951
// 83.166.240.184:7951
// 83.166.241.9:7951
// 83.166.241.120:7951
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question