w-ipproxy 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -80,7 +80,7 @@
80
80
 
81
81
  <dt class="tag-source">Source:</dt>
82
82
  <dd class="tag-source"><ul class="dummy"><li>
83
- <a href="WIpProxy.mjs.html">WIpProxy.mjs</a>, <a href="WIpProxy.mjs.html#line62">line 62</a>
83
+ <a href="WIpProxy.mjs.html">WIpProxy.mjs</a>, <a href="WIpProxy.mjs.html#line63">line 63</a>
84
84
  </li></ul></dd>
85
85
 
86
86
 
@@ -127,7 +127,7 @@
127
127
 
128
128
  <h5 class="h5-examples">Example</h5>
129
129
 
130
- <pre class="prettyprint"><code>import _ from 'lodash-es'
131
130
  // tar: `https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT`,
132
131
  withServer: true,
133
132
  serverPort: 9000,
134
133
  serverCorsOrigins: ['*'],
135
134
  console.log(`已抓取公開代理共 ${_.size(prxsRaw)} 個...`)
136
135
  // console.log('新加入代理', { host: p.host, port: p.port }, _.map(proxies, 'proxy'))
137
136
  // console.log('刪除代理', { host: p.host, port: p.port }, _.map(proxies, 'proxy'))
138
137
  // console.log(`有效代理`, _.map(proxies, 'proxy'))
139
138
  console.log(`已檢測有效代理共 ${_.size(proxies)} 個...`)
139
+ <pre class="prettyprint"><code>import _ from 'lodash-es'
140
140
  // tar: `https://www.google.com`,
141
141
  withServer: true,
142
142
  serverPort: 9000,
143
143
  serverCorsOrigins: ['*'],
144
144
  console.log(`已抓取公開代理共 ${_.size(prxsRaw)} 個...`)
145
145
  // console.log('新加入代理', { host: p.host, port: p.port }, _.map(proxies, 'proxy'))
146
146
  // console.log('刪除代理', { host: p.host, port: p.port }, _.map(proxies, 'proxy'))
147
147
  // console.log(`有效代理`, _.map(proxies, 'proxy'))
148
148
  console.log(`已檢測有效代理共 ${_.size(proxies)} 個...`)
149
149
 
150
150
 
151
151
 
@@ -629,7 +629,7 @@
629
629
  <br class="clear">
630
630
 
631
631
  <footer>
632
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Fri Mar 21 2025 12:49:33 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
632
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Mar 17 2026 21:42:27 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
633
633
  </footer>
634
634
 
635
635
  <script>prettyPrint();</script>
@@ -59,6 +59,7 @@ import isestr from 'wsemi/src/isestr.mjs'
59
59
  import ispint from 'wsemi/src/ispint.mjs'
60
60
  import isbol from 'wsemi/src/isbol.mjs'
61
61
  import isearr from 'wsemi/src/isearr.mjs'
62
+ import iseobj from 'wsemi/src/iseobj.mjs'
62
63
  import cint from 'wsemi/src/cint.mjs'
63
64
  import waitFun from 'wsemi/src/waitFun.mjs'
64
65
  import provideServer from './provideServer.mjs'
@@ -84,7 +85,7 @@ import provideServer from './provideServer.mjs'
84
85
  * import wip from './src/WIpProxy.mjs'
85
86
  *
86
87
  * let wo = wip({
87
- * // tar: `https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT`,
88
+ * // tar: `https://www.google.com`,
88
89
  * withServer: true,
89
90
  * serverPort: 9000,
90
91
  * serverCorsOrigins: ['*'],
@@ -206,12 +207,31 @@ function WIpProxy(opt = {}) {
206
207
  return ps
207
208
  }
208
209
 
210
+ let b_getProxies = false
209
211
  async function _getProxies() {
210
212
  // console.log('call getProxies...')
211
- prxsRaw = await _getProxiesCore(src)
212
- .catch(() => {})
213
- // console.log('call getProxies fin')
214
- ev.emit('getRawProxies', prxsRaw)
213
+
214
+ let core = async() => {
215
+
216
+ //get
217
+ prxsRaw = await _getProxiesCore(src)
218
+
219
+ //emit
220
+ ev.emit('getRawProxies', prxsRaw)
221
+
222
+ }
223
+
224
+ //core
225
+ if (b_getProxies) {
226
+ return
227
+ }
228
+ b_getProxies = true
229
+ await core()
230
+ .catch(() => {}) //吃掉錯誤
231
+ .finally(() => {
232
+ b_getProxies = false
233
+ })
234
+
215
235
  }
216
236
 
217
237
  async function _testProxyCore(host, port, url) {
@@ -286,18 +306,31 @@ function WIpProxy(opt = {}) {
286
306
  let psValid = []
287
307
  let psInvalid = []
288
308
  each(rrs, (v) => {
309
+
310
+ //be
311
+ let p = get(v, 'value.p', null)
312
+ let be = iseobj(p) &amp;&amp; isestr(get(p, 'proxy'))
313
+
314
+ //check
315
+ if (!be) {
316
+ return true //跳出換下一個
317
+ }
318
+
319
+ //b
289
320
  let status = get(v, 'status', '')
290
321
  let b1 = status === 'fulfilled'
291
322
  let state = get(v, 'value.state', '')
292
323
  let b2 = state === 'success'
293
324
  let b = b1 &amp;&amp; b2
294
- let p = get(v, 'value.p', null)
325
+
326
+ //push
295
327
  if (b) {
296
328
  psValid.push(p)
297
329
  }
298
330
  else {
299
331
  psInvalid.push(p)
300
332
  }
333
+
301
334
  })
302
335
 
303
336
  return {
@@ -306,19 +339,65 @@ function WIpProxy(opt = {}) {
306
339
  }
307
340
  }
308
341
 
342
+ let b_testProxies = false
309
343
  async function _testProxies() {
310
344
  // console.log('call testProxies...')
311
- let r = await _testProxiesCore(prxsRaw)
312
- each(r.psValid, (p) => {
313
- kpPrx[p.proxy] = p
314
- ev.emit('add', p, values(kpPrx))
315
- })
316
- each(r.psInvalid, (p) => {
317
- delete kpPrx[p.proxy]
318
- ev.emit('delete', p, values(kpPrx))
319
- })
320
- ev.emit('change', values(kpPrx))
321
- // console.log('call testProxies fin')
345
+
346
+ let core = async() => {
347
+
348
+ //get
349
+ let r = await _testProxiesCore(prxsRaw)
350
+
351
+ //emit add
352
+ each(r.psValid, (p) => {
353
+ kpPrx[p.proxy] = p
354
+ ev.emit('add', p, values(kpPrx))
355
+ })
356
+
357
+ //emit delete
358
+ each(r.psInvalid, (p) => {
359
+ delete kpPrx[p.proxy]
360
+ ev.emit('delete', p, values(kpPrx))
361
+ })
362
+
363
+ //emit change
364
+ ev.emit('change', values(kpPrx))
365
+
366
+ }
367
+
368
+ //core
369
+ if (b_testProxies) {
370
+ return
371
+ }
372
+ b_testProxies = true
373
+ await core()
374
+ .catch(() => {}) //吃掉錯誤
375
+ .finally(() => {
376
+ b_testProxies = false
377
+ })
378
+
379
+ }
380
+
381
+ function init() {
382
+
383
+ //取得代理清單
384
+ if (true) {
385
+ _getProxies()
386
+ setInterval(() => {
387
+ _getProxies()
388
+ }, timeGetProxies)
389
+ }
390
+
391
+ //過濾出有效代理清單, 延遲3s觸發, 給時間抓取
392
+ if (true) {
393
+ setTimeout(() => {
394
+ _testProxies()
395
+ setInterval(() => {
396
+ _testProxies()
397
+ }, timeTestProxies)
398
+ }, 3000)
399
+ }
400
+
322
401
  }
323
402
 
324
403
  async function getProxies() {
@@ -333,23 +412,6 @@ function WIpProxy(opt = {}) {
333
412
  //ev
334
413
  let ev = evem()
335
414
 
336
- //取得代理清單
337
- if (true) {
338
- _getProxies()
339
- setInterval(() => {
340
- _getProxies()
341
- }, timeGetProxies)
342
- }
343
-
344
- //過濾出有效代理清單, 延遲3s觸發, 給時間抓取
345
- setTimeout(() => {
346
- _testProxies()
347
- setInterval(() => {
348
- _testProxies()
349
- .catch(() => {})
350
- }, timeTestProxies)
351
- }, 3000)
352
-
353
415
  //withServer
354
416
  if (withServer) {
355
417
  provideServer(getProxies, {
@@ -359,8 +421,17 @@ function WIpProxy(opt = {}) {
359
421
  })
360
422
  }
361
423
 
424
+ async function getProxiesOnce() {
425
+ await _getProxies()
426
+ await _testProxies()
427
+ let ps = await getProxies()
428
+ return ps
429
+ }
430
+
362
431
  //save
432
+ ev.init = init
363
433
  ev.getProxies = getProxies
434
+ ev.getProxiesOnce = getProxiesOnce
364
435
 
365
436
  return ev
366
437
  }
@@ -381,7 +452,7 @@ export default WIpProxy
381
452
  <br class="clear">
382
453
 
383
454
  <footer>
384
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Fri Mar 21 2025 12:49:33 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
455
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Mar 17 2026 21:42:27 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
385
456
  </footer>
386
457
 
387
458
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -71,7 +71,7 @@
71
71
  <br class="clear">
72
72
 
73
73
  <footer>
74
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Fri Mar 21 2025 12:49:33 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
74
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Mar 17 2026 21:42:27 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
75
75
  </footer>
76
76
 
77
77
  <script>prettyPrint();</script>
@@ -5,6 +5,7 @@ import wip from './src/WIpProxy.mjs'
5
5
  let wo = wip({
6
6
  // tar: `https://www.google.com`,
7
7
  })
8
+ wo.init()
8
9
  wo.on('getRawProxies', (prxsRaw) => {
9
10
  console.log(`已抓取公開代理共 ${_.size(prxsRaw)} 個...`)
10
11
  })
@@ -20,4 +21,4 @@ wo.on('change', (proxies) => {
20
21
  })
21
22
 
22
23
 
23
- //node --experimental-modules g-get.mjs
24
+ //node g-getByTimer.mjs
package/g-getOnce.mjs ADDED
@@ -0,0 +1,11 @@
1
+ import wip from './src/WIpProxy.mjs'
2
+
3
+
4
+ let wo = wip({
5
+ // tar: `https://www.google.com`,
6
+ })
7
+ let ps = await wo.getProxiesOnce()
8
+ console.log('ps', ps)
9
+
10
+
11
+ //node g-getOnce.mjs
package/g-srv.mjs CHANGED
@@ -3,7 +3,7 @@ import wip from './src/WIpProxy.mjs'
3
3
 
4
4
 
5
5
  let wo = wip({
6
- // tar: `https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT`,
6
+ // tar: `https://www.google.com`,
7
7
  withServer: true,
8
8
  serverPort: 9000,
9
9
  serverCorsOrigins: ['*'],
@@ -25,4 +25,4 @@ wo.on('change', (proxies) => {
25
25
  //browser view: http://localhost:9000/getProxies
26
26
 
27
27
 
28
- //node --experimental-modules g-srv.mjs
28
+ //node g-srv.mjs
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "w-ipproxy",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "main": "dist/w-ipproxy.umd.js",
5
5
  "dependencies": {
6
- "@hapi/hapi": "^21.4.0",
7
- "axios": "^1.8.4",
8
- "cheerio": "^1.0.0",
9
- "lodash-es": "^4.17.21",
10
- "wsemi": "^1.7.71"
6
+ "@hapi/hapi": "^21.4.7",
7
+ "axios": "^1.13.6",
8
+ "cheerio": "^1.2.0",
9
+ "lodash-es": "^4.17.23",
10
+ "wsemi": "^1.8.43"
11
11
  },
12
12
  "devDependencies": {
13
- "w-package-tools": "^1.0.82"
13
+ "w-package-tools": "^1.1.3"
14
14
  },
15
15
  "scripts": {
16
- "test": "mocha --parallel --timeout 60000 --experimental-modules",
16
+ "test": "mocha --parallel --timeout 60000",
17
17
  "deploy": "gh-pages -d docs"
18
18
  },
19
19
  "repository": {
@@ -30,4 +30,4 @@
30
30
  ],
31
31
  "author": "yuda-lyu(semisphere)",
32
32
  "license": "MIT"
33
- }
33
+ }
package/script.txt CHANGED
@@ -1,10 +1,10 @@
1
- #node --experimental-modules toolg/addVersion.mjs
2
- node --experimental-modules toolg/modifyReadme.mjs
1
+ #node toolg/addVersion.mjs
2
+ node toolg/modifyReadme.mjs
3
3
 
4
- node --experimental-modules toolg/cleanFolder.mjs
4
+ node toolg/cleanFolder.mjs
5
5
  ./node_modules/.bin/jsdoc -c .jsdoc
6
6
 
7
- node --experimental-modules toolg/gDistRollup.mjs
7
+ node toolg/gDistRollup.mjs
8
8
 
9
9
  git add . -A
10
10
  git commit -m 'modify: '
@@ -15,4 +15,3 @@ npm run deploy
15
15
  #npm test
16
16
 
17
17
  #npm publish
18
-
package/src/WIpProxy.mjs CHANGED
@@ -12,6 +12,7 @@ import isestr from 'wsemi/src/isestr.mjs'
12
12
  import ispint from 'wsemi/src/ispint.mjs'
13
13
  import isbol from 'wsemi/src/isbol.mjs'
14
14
  import isearr from 'wsemi/src/isearr.mjs'
15
+ import iseobj from 'wsemi/src/iseobj.mjs'
15
16
  import cint from 'wsemi/src/cint.mjs'
16
17
  import waitFun from 'wsemi/src/waitFun.mjs'
17
18
  import provideServer from './provideServer.mjs'
@@ -37,7 +38,7 @@ import provideServer from './provideServer.mjs'
37
38
  * import wip from './src/WIpProxy.mjs'
38
39
  *
39
40
  * let wo = wip({
40
- * // tar: `https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT`,
41
+ * // tar: `https://www.google.com`,
41
42
  * withServer: true,
42
43
  * serverPort: 9000,
43
44
  * serverCorsOrigins: ['*'],
@@ -159,12 +160,31 @@ function WIpProxy(opt = {}) {
159
160
  return ps
160
161
  }
161
162
 
163
+ let b_getProxies = false
162
164
  async function _getProxies() {
163
165
  // console.log('call getProxies...')
164
- prxsRaw = await _getProxiesCore(src)
165
- .catch(() => {})
166
- // console.log('call getProxies fin')
167
- ev.emit('getRawProxies', prxsRaw)
166
+
167
+ let core = async() => {
168
+
169
+ //get
170
+ prxsRaw = await _getProxiesCore(src)
171
+
172
+ //emit
173
+ ev.emit('getRawProxies', prxsRaw)
174
+
175
+ }
176
+
177
+ //core
178
+ if (b_getProxies) {
179
+ return
180
+ }
181
+ b_getProxies = true
182
+ await core()
183
+ .catch(() => {}) //吃掉錯誤
184
+ .finally(() => {
185
+ b_getProxies = false
186
+ })
187
+
168
188
  }
169
189
 
170
190
  async function _testProxyCore(host, port, url) {
@@ -239,18 +259,31 @@ function WIpProxy(opt = {}) {
239
259
  let psValid = []
240
260
  let psInvalid = []
241
261
  each(rrs, (v) => {
262
+
263
+ //be
264
+ let p = get(v, 'value.p', null)
265
+ let be = iseobj(p) && isestr(get(p, 'proxy'))
266
+
267
+ //check
268
+ if (!be) {
269
+ return true //跳出換下一個
270
+ }
271
+
272
+ //b
242
273
  let status = get(v, 'status', '')
243
274
  let b1 = status === 'fulfilled'
244
275
  let state = get(v, 'value.state', '')
245
276
  let b2 = state === 'success'
246
277
  let b = b1 && b2
247
- let p = get(v, 'value.p', null)
278
+
279
+ //push
248
280
  if (b) {
249
281
  psValid.push(p)
250
282
  }
251
283
  else {
252
284
  psInvalid.push(p)
253
285
  }
286
+
254
287
  })
255
288
 
256
289
  return {
@@ -259,19 +292,65 @@ function WIpProxy(opt = {}) {
259
292
  }
260
293
  }
261
294
 
295
+ let b_testProxies = false
262
296
  async function _testProxies() {
263
297
  // console.log('call testProxies...')
264
- let r = await _testProxiesCore(prxsRaw)
265
- each(r.psValid, (p) => {
266
- kpPrx[p.proxy] = p
267
- ev.emit('add', p, values(kpPrx))
268
- })
269
- each(r.psInvalid, (p) => {
270
- delete kpPrx[p.proxy]
271
- ev.emit('delete', p, values(kpPrx))
272
- })
273
- ev.emit('change', values(kpPrx))
274
- // console.log('call testProxies fin')
298
+
299
+ let core = async() => {
300
+
301
+ //get
302
+ let r = await _testProxiesCore(prxsRaw)
303
+
304
+ //emit add
305
+ each(r.psValid, (p) => {
306
+ kpPrx[p.proxy] = p
307
+ ev.emit('add', p, values(kpPrx))
308
+ })
309
+
310
+ //emit delete
311
+ each(r.psInvalid, (p) => {
312
+ delete kpPrx[p.proxy]
313
+ ev.emit('delete', p, values(kpPrx))
314
+ })
315
+
316
+ //emit change
317
+ ev.emit('change', values(kpPrx))
318
+
319
+ }
320
+
321
+ //core
322
+ if (b_testProxies) {
323
+ return
324
+ }
325
+ b_testProxies = true
326
+ await core()
327
+ .catch(() => {}) //吃掉錯誤
328
+ .finally(() => {
329
+ b_testProxies = false
330
+ })
331
+
332
+ }
333
+
334
+ function init() {
335
+
336
+ //取得代理清單
337
+ if (true) {
338
+ _getProxies()
339
+ setInterval(() => {
340
+ _getProxies()
341
+ }, timeGetProxies)
342
+ }
343
+
344
+ //過濾出有效代理清單, 延遲3s觸發, 給時間抓取
345
+ if (true) {
346
+ setTimeout(() => {
347
+ _testProxies()
348
+ setInterval(() => {
349
+ _testProxies()
350
+ }, timeTestProxies)
351
+ }, 3000)
352
+ }
353
+
275
354
  }
276
355
 
277
356
  async function getProxies() {
@@ -286,23 +365,6 @@ function WIpProxy(opt = {}) {
286
365
  //ev
287
366
  let ev = evem()
288
367
 
289
- //取得代理清單
290
- if (true) {
291
- _getProxies()
292
- setInterval(() => {
293
- _getProxies()
294
- }, timeGetProxies)
295
- }
296
-
297
- //過濾出有效代理清單, 延遲3s觸發, 給時間抓取
298
- setTimeout(() => {
299
- _testProxies()
300
- setInterval(() => {
301
- _testProxies()
302
- .catch(() => {})
303
- }, timeTestProxies)
304
- }, 3000)
305
-
306
368
  //withServer
307
369
  if (withServer) {
308
370
  provideServer(getProxies, {
@@ -312,8 +374,17 @@ function WIpProxy(opt = {}) {
312
374
  })
313
375
  }
314
376
 
377
+ async function getProxiesOnce() {
378
+ await _getProxies()
379
+ await _testProxies()
380
+ let ps = await getProxies()
381
+ return ps
382
+ }
383
+
315
384
  //save
385
+ ev.init = init
316
386
  ev.getProxies = getProxies
387
+ ev.getProxiesOnce = getProxiesOnce
317
388
 
318
389
  return ev
319
390
  }