剖析正则 
说明
parse- 代理服务器是一个轻量级节点. js 代理字符串解析库
它会做什么:
- 将一串代理对象解析成一系列代理对象
- 支持多个分隔符(comma、新行、空格)
- 支持代理认证
- 支持代理协议
安装
npm install @devhigley/parse-proxy
yarn add @devhigley/parse-proxy
使用量
按逗号和空格划分的基本示例 :
const parseProxy = require("@devhigley/parse-proxy");
parseProxy(`1.1.1.1:80, 2.2.2.2:80, 3.3.3.3:80`);
结果 :
[
{ host: '1.1.1.1', port: 80, protocol: 'http' },
{ host: '2.2.2.2', port: 80, protocol: 'http' },
{ host: '3.3.3.3', port: 80, protocol: 'http' }
]
带有协议和认证的示例,用新行分隔:
const parseProxy = require("@devhigley/parse-proxy");
parseProxy(`https://user:[email protected]:8080
https://user:[email protected]:3128`);
结果 :
[
{
host: '104.236.55.48',
port: 8080,
protocol: 'https',
auth: { username: 'user', password: 'pass' }
},
{
host: '213.105.29.14',
port: 3128,
protocol: 'https',
auth: { username: 'user', password: 'pass' }
}
]