w-ipproxy 1.0.1
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.
- package/.editorconfig +9 -0
- package/.eslintignore +3 -0
- package/.eslintrc.js +54 -0
- package/.github/workflows/ci-test.yml +24 -0
- package/.jsdoc +25 -0
- package/LICENSE +21 -0
- package/README.md +10 -0
- package/SECURITY.md +5 -0
- package/babel.config.js +14 -0
- package/g.mjs +12 -0
- package/package.json +31 -0
- package/src/WIpProxy.mjs +23 -0
- package/src/getHtml.mjs +84 -0
- package/src/getProxyListOrg.mjs +66 -0
- package/src/parseHtml.mjs +19 -0
- package/test/all.test.mjs +10 -0
- package/toolg/addVersion.mjs +4 -0
package/.editorconfig
ADDED
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": true,
|
|
4
|
+
"es6": true,
|
|
5
|
+
"mocha": true
|
|
6
|
+
},
|
|
7
|
+
"extends": ["plugin:vue/base", "plugin:vue/essential", "standard"],
|
|
8
|
+
"plugins": [
|
|
9
|
+
"vue"
|
|
10
|
+
],
|
|
11
|
+
"globals": {
|
|
12
|
+
"Atomics": "readonly",
|
|
13
|
+
"SharedArrayBuffer": "readonly"
|
|
14
|
+
},
|
|
15
|
+
"parser": "vue-eslint-parser",
|
|
16
|
+
"parserOptions": {
|
|
17
|
+
"parser": "babel-eslint",
|
|
18
|
+
"ecmaVersion": 2019,
|
|
19
|
+
"sourceType": "module",
|
|
20
|
+
},
|
|
21
|
+
rules: {
|
|
22
|
+
'generator-star-spacing': 'off',
|
|
23
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
24
|
+
'indent': ['error', 4],
|
|
25
|
+
'no-console': 'off',
|
|
26
|
+
'comma-dangle': ['error', {
|
|
27
|
+
'arrays': 'ignore',
|
|
28
|
+
'objects': 'ignore',
|
|
29
|
+
'imports': 'never',
|
|
30
|
+
'exports': 'never',
|
|
31
|
+
'functions': 'ignore'
|
|
32
|
+
}],
|
|
33
|
+
'no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 2 }],
|
|
34
|
+
//'space-before-function-paren': ['error', { 'anonymous': 'always', 'named': 'never' }],
|
|
35
|
+
'space-before-function-paren': 'off',
|
|
36
|
+
'spaced-comment': 'off',
|
|
37
|
+
'brace-style': ['error', 'stroustrup'],
|
|
38
|
+
'padded-blocks': 'off',
|
|
39
|
+
'no-constant-condition': 'off',
|
|
40
|
+
'camelcase': 'off',
|
|
41
|
+
'no-new': 'off',
|
|
42
|
+
'prefer-const': 'off',
|
|
43
|
+
'quote-props': ['error', 'consistent'],
|
|
44
|
+
'dot-notation': 'off',
|
|
45
|
+
'standard/no-callback-literal': 'off',
|
|
46
|
+
'quotes': ['error', 'single', { 'allowTemplateLiterals': true }],
|
|
47
|
+
'prefer-promise-reject-errors': 'off',
|
|
48
|
+
'no-unused-vars': ['error', { 'args': 'none', 'ignoreRestSiblings': true, 'argsIgnorePattern': '^_' }],
|
|
49
|
+
'node/no-callback-literal': 'off',
|
|
50
|
+
'prefer-regex-literals': 'off',
|
|
51
|
+
'array-callback-return': 'off',
|
|
52
|
+
'no-unreachable-loop': 'off',
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Node.js CI
|
|
2
|
+
|
|
3
|
+
on: [push]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
|
|
10
|
+
strategy:
|
|
11
|
+
matrix:
|
|
12
|
+
node-version: [16.x]
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v2
|
|
16
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
17
|
+
uses: actions/setup-node@v1
|
|
18
|
+
with:
|
|
19
|
+
node-version: ${{ matrix.node-version }}
|
|
20
|
+
- run: npm cache clean -f
|
|
21
|
+
- run: npm install
|
|
22
|
+
- run: npm test
|
|
23
|
+
env:
|
|
24
|
+
CI: true
|
package/.jsdoc
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tags": {
|
|
3
|
+
"allowUnknownTags": false
|
|
4
|
+
},
|
|
5
|
+
"source": {
|
|
6
|
+
"include": ["src/", "server/"],
|
|
7
|
+
"includePattern": ".+\\.(js(doc|x)?|mjs|vue)$",
|
|
8
|
+
"excludePattern": "(node_modules/|docs)"
|
|
9
|
+
},
|
|
10
|
+
"plugins": [
|
|
11
|
+
"plugins/markdown",
|
|
12
|
+
"node_modules/jsdoc-vuejs"
|
|
13
|
+
],
|
|
14
|
+
"opts": {
|
|
15
|
+
"template": "node_modules/docdash",
|
|
16
|
+
"encoding": "utf8",
|
|
17
|
+
"destination": "docs/",
|
|
18
|
+
"recurse": true,
|
|
19
|
+
"verbose": true
|
|
20
|
+
},
|
|
21
|
+
"templates": {
|
|
22
|
+
"cleverLinks": false,
|
|
23
|
+
"monospaceLinks": false
|
|
24
|
+
}
|
|
25
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 semisphere(yu-da, lyu 呂昱達)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# w-ipproxy
|
|
2
|
+
IP proxy list.
|
|
3
|
+
|
|
4
|
+

|
|
5
|
+
[](https://npmjs.org/package/w-ipproxy)
|
|
6
|
+
[](https://npmjs.org/package/w-ipproxy)
|
|
7
|
+
[](https://github.com/yuda-lyu/w-ipproxy)
|
|
8
|
+
[](https://npmjs.org/package/w-ipproxy)
|
|
9
|
+
[](https://www.jsdelivr.com/package/npm/w-ipproxy)
|
|
10
|
+
|
package/SECURITY.md
ADDED
package/babel.config.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
'presets': [
|
|
3
|
+
['@babel/preset-env', {
|
|
4
|
+
'useBuiltIns': 'entry',
|
|
5
|
+
'corejs': 3
|
|
6
|
+
}]
|
|
7
|
+
],
|
|
8
|
+
'plugins': [
|
|
9
|
+
'@babel/plugin-transform-runtime',
|
|
10
|
+
'@babel/plugin-proposal-export-default-from',
|
|
11
|
+
'@babel/plugin-proposal-nullish-coalescing-operator',
|
|
12
|
+
'@babel/plugin-proposal-optional-chaining'
|
|
13
|
+
]
|
|
14
|
+
}
|
package/g.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "w-ipproxy",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"main": "dist/w-ipproxy.umd.js",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"axios": "^1.2.3",
|
|
7
|
+
"cheerio": "^1.0.0-rc.12",
|
|
8
|
+
"lodash": "^4.17.21",
|
|
9
|
+
"puppeteer": "^19.5.2",
|
|
10
|
+
"wsemi": "^1.6.87"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"w-package-tools": "^1.0.66"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "mocha --parallel --timeout 60000 --experimental-modules --es-module-specifier-resolution=node",
|
|
17
|
+
"deploy": "gh-pages -d docs"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/yuda-lyu/w-ipproxy"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"package",
|
|
25
|
+
"tool",
|
|
26
|
+
"ip",
|
|
27
|
+
"proxy"
|
|
28
|
+
],
|
|
29
|
+
"author": "yuda-lyu(semisphere)",
|
|
30
|
+
"license": "MIT"
|
|
31
|
+
}
|
package/src/WIpProxy.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import getProxyListOrg from './getProxyListOrg.mjs'
|
|
2
|
+
|
|
3
|
+
//freeproxylists
|
|
4
|
+
//http://www.freeproxylists.net/zh/?c=&pt=&pr=&a%5B%5D=0&a%5B%5D=1&a%5B%5D=2&u=0
|
|
5
|
+
|
|
6
|
+
//aliveproxy
|
|
7
|
+
//http://www.aliveproxy.com/proxy-list/proxies.aspx/Taiwan-tw
|
|
8
|
+
|
|
9
|
+
//cnproxy
|
|
10
|
+
//http://www.cnproxy.com/proxy1.html
|
|
11
|
+
|
|
12
|
+
async function WIpProxy() {
|
|
13
|
+
let rs = []
|
|
14
|
+
let r
|
|
15
|
+
|
|
16
|
+
//getProxyListOrg
|
|
17
|
+
r = await getProxyListOrg()
|
|
18
|
+
rs = [...rs, ...r]
|
|
19
|
+
|
|
20
|
+
return rs
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default WIpProxy
|
package/src/getHtml.mjs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import puppeteer from 'puppeteer'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
async function getHtml(url, selector, muti = false) {
|
|
5
|
+
|
|
6
|
+
async function view(url) {
|
|
7
|
+
|
|
8
|
+
//new page
|
|
9
|
+
let olaunch = {
|
|
10
|
+
//timeout: 0,
|
|
11
|
+
headless: false,
|
|
12
|
+
slowMo: 20,
|
|
13
|
+
// arg: [
|
|
14
|
+
// //`--window-size=${viewport.width},${viewport.height}`, //無效
|
|
15
|
+
// //`--disable-resize-lock`, //無效
|
|
16
|
+
// ],
|
|
17
|
+
// defaultViewport: { //無效
|
|
18
|
+
// x: 0,
|
|
19
|
+
// y: 0,
|
|
20
|
+
// width: 800,
|
|
21
|
+
// height: 600,
|
|
22
|
+
// }
|
|
23
|
+
}
|
|
24
|
+
let browser = await puppeteer.launch(olaunch)
|
|
25
|
+
let page = await browser.newPage()
|
|
26
|
+
|
|
27
|
+
//show page
|
|
28
|
+
await page.goto(url)
|
|
29
|
+
let viewport = {
|
|
30
|
+
x: 0,
|
|
31
|
+
y: 0,
|
|
32
|
+
width: 800,
|
|
33
|
+
height: 600,
|
|
34
|
+
}
|
|
35
|
+
await page.setViewport(viewport)
|
|
36
|
+
|
|
37
|
+
//wait
|
|
38
|
+
let waitsec = 5
|
|
39
|
+
await page.waitFor(waitsec * 1000)
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
browser,
|
|
43
|
+
page,
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function close(p) {
|
|
48
|
+
|
|
49
|
+
//close
|
|
50
|
+
await p.page.close()
|
|
51
|
+
await p.browser.close()
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function g1(p, selector) {
|
|
56
|
+
return await p.page.$eval(selector, (node) => {
|
|
57
|
+
return node.innerHTML
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function gs(p, selector) {
|
|
62
|
+
return await p.page.$$eval(selector, (nodes) => {
|
|
63
|
+
return nodes.map((node) => {
|
|
64
|
+
return node.innerHTML
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let p = await view(url)
|
|
70
|
+
|
|
71
|
+
let r
|
|
72
|
+
if (muti) {
|
|
73
|
+
r = await gs(p, selector)
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
r = await g1(p, selector)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
close(p)
|
|
80
|
+
|
|
81
|
+
return r
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default getHtml
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// import fs from 'fs'
|
|
2
|
+
import get from 'lodash/get'
|
|
3
|
+
import sep from 'wsemi/src/sep.mjs'
|
|
4
|
+
import pmMap from 'wsemi/src/pmMap.mjs'
|
|
5
|
+
import parseHtml from './parseHtml.mjs'
|
|
6
|
+
import getHtml from './getHtml.mjs'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async function core(url) {
|
|
10
|
+
let ps = []
|
|
11
|
+
|
|
12
|
+
let selector = 'div.table'
|
|
13
|
+
let h = await getHtml(url, selector)
|
|
14
|
+
// fs.writeFileSync('temp.html', h)
|
|
15
|
+
// let h = fs.readFileSync('tempProxyListOrg.html', 'utf8')
|
|
16
|
+
|
|
17
|
+
//parseHtml
|
|
18
|
+
let $ = parseHtml(h)
|
|
19
|
+
$('ul').map((k, v) => {
|
|
20
|
+
let q = $(v)
|
|
21
|
+
|
|
22
|
+
let proxy = q.children('li.proxy').html()
|
|
23
|
+
proxy = sep(proxy, 'script>')
|
|
24
|
+
proxy = get(proxy, 1)
|
|
25
|
+
// console.log(k,'proxy',proxy)
|
|
26
|
+
|
|
27
|
+
let httpType = q.children('li.https').text()
|
|
28
|
+
// console.log(k,'httpType',httpType)
|
|
29
|
+
|
|
30
|
+
let country = q.find('span.country').text()
|
|
31
|
+
// console.log(k,'country',country)
|
|
32
|
+
|
|
33
|
+
let countryName = q.find('span.name').attr('name')
|
|
34
|
+
// console.log(k,'countryName',countryName)
|
|
35
|
+
|
|
36
|
+
ps.push({
|
|
37
|
+
proxy,
|
|
38
|
+
httpType,
|
|
39
|
+
country,
|
|
40
|
+
countryName,
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
return ps
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function getProxyListOrg() {
|
|
48
|
+
let psAll = []
|
|
49
|
+
|
|
50
|
+
await pmMap([1, 2, 3], async(v) => {
|
|
51
|
+
// console.log(v)
|
|
52
|
+
|
|
53
|
+
//url
|
|
54
|
+
//let url = 'https://proxy-list.org/chinese/index.php?setlang=chinese'
|
|
55
|
+
let url = `https://proxy-list.org/chinese/index.php?setlang=chinese&p=${v}`
|
|
56
|
+
|
|
57
|
+
//core
|
|
58
|
+
let ps = await core(url)
|
|
59
|
+
psAll = [...psAll, ...ps]
|
|
60
|
+
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
return psAll
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default getProxyListOrg
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import cheerio from 'cheerio'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function parseHtml(h) {
|
|
6
|
+
|
|
7
|
+
let $setting = {
|
|
8
|
+
//ignoreWhitespace: true,
|
|
9
|
+
xmlMode: true,
|
|
10
|
+
decodeEntities: false,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//$
|
|
14
|
+
let $ = cheerio.load(h, $setting)
|
|
15
|
+
|
|
16
|
+
return $
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default parseHtml
|