Skip to content

Instantly share code, notes, and snippets.

@Subi
Created June 27, 2020 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Subi/bd1be2f868e05298909f8c2d6b1515dc to your computer and use it in GitHub Desktop.
Save Subi/bd1be2f868e05298909f8c2d6b1515dc to your computer and use it in GitHub Desktop.
Read a list of proxies from text file and format them for JSON
const fs = require('fs');
const proxies = fs.readFileSync('proxies.txt', 'utf-8');
let splitProxies = proxies.split('\n');
let output = splitProxies.map((proxy, index) => {
sanatizeProxy = proxy.replace('\r', '');
if (splitProxies[index + 1] != undefined) {
return `"${sanatizeProxy}",`;
}
return `"${sanatizeProxy}"`;
});
console.log(output.join('\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment