Last active
June 1, 2019 13:49
-
-
Save miraris/1827e5f98967af691d4b66526aa026c8 to your computer and use it in GitHub Desktop.
Simple ES6 function to get an array of proxy objects, ready to be plugged into axios
This file contains 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 got = require("got"); | |
const regex = /(?<host>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\:?(?<port>[0-9]{1,5})?/; | |
const getProxy = () => | |
got("http://spys.me/proxy.txt").then(({ body }) => | |
body | |
.split("\n") | |
.filter(val => regex.test(val)) | |
.map(val => { | |
const { | |
groups: { host, port } | |
} = regex.exec(val); | |
return { | |
host, | |
port | |
}; | |
}) | |
); | |
getProxy().then(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment