Created
June 27, 2020 19:45
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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