README.md 646 Bytes
Newer Older
Francis's avatar
Francis committed
1
2
3
4
5
6
7
8
9
### 安装

> npm i --save git+http://git.xemestudio.com/francis/proxies-client.git

### 使用

~~~ js
const ProxyClient = require('proxy-client')

Francis's avatar
Francis committed
10
// 链接至代理池
Francis's avatar
Francis committed
11
12
13
14
15
ProxyClient.config({
  port: 4000,
  host: '127.0.0.1',
})

Francis's avatar
Francis committed
16
17
// 增加代理
// 会在增加代理时对代理进行验证
Francis's avatar
Francis committed
18
19
20
21
22
23
24
25
26
27
ProxyClient
  .addProxy({ip: '10.0.0.1', port: '8081'})
  .then(() => {
    # next
  })
  .catch((err) => {
    console.log(err)
  })
  
  
Francis's avatar
Francis committed
28
// 获取代理列表
Francis's avatar
Francis committed
29
30
31
32
33
34
35
36
37
38
ProxyClient
  .fetchProxies(10)
  .then((proxies) => {
    console.log(proxies)
    // 包含 { ip: 'xxx', port: 'xxx' } 对象的数组
  })
  .catch((err) => {
    console.log(err)
  })
~~~