Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit dc14e96

Browse files
author
yanqi.zong
committed
拆分
1 parent 6964011 commit dc14e96

File tree

8 files changed

+65
-54
lines changed

8 files changed

+65
-54
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
.DS_Store
3-
npm-debug.log
3+
npm-debug.log
4+
.idea

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 谷歌镜像搜集
1+
# 谷歌镜像搜集+检测
22

33
使用方法:
44

@@ -13,3 +13,9 @@ google.check()
1313
})
1414
})
1515
```
16+
17+
如果你有更多的镜像请加入到 `./src/mirrors.js`,
18+
如果你有更多的变种网页请加入到 `./src/variants.js`,
19+
如果你有更好的检测方法, 请修改 `./index.js`
20+
21+
愿每个人都可以自由的获取信息.

index.js

+26-49
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,45 @@ var request = require('request-promise');
22
var promise = require('promise');
33
var uniq = require('uniq');
44

5-
var siteType = {
6-
mirror: 2,
7-
variant: 1
8-
}
5+
var siteType = require('./src/siteType');
6+
var mirrors = require('./src/mirrors');
7+
var variants = require('./src/variants');
98

10-
var mirrors = uniq([
11-
'http://g.jiasubao.co/',
12-
'http://gc.ihuan.me/',
13-
'http://ggss.cf/',
14-
'http://gogoogle.ml/',
15-
'http://google.casejs.com/',
16-
'http://hao.cytbj.com/',
17-
'http://rose.jgoproxy.tk/',
18-
'http://s.8090st.com/',
19-
'http://soguge.com/',
20-
'http://www.wen.lu/',
21-
'http://www.zzq2.com/',
22-
'https://g2.wen.lu/',
23-
'https://gg.kfd.me/',
24-
'https://ggg.eeload.com/',
25-
'https://go.cccyun.cn/',
26-
'https://jisuobuyu.com/',
27-
'https://www.iamgg.pw/',
28-
'https://www.onenew.net/'
29-
]).map(function(url) {
30-
return { url: url, type: 'mirror', time: 0 };
31-
})
32-
33-
;
34-
35-
var variants = uniq([])
36-
.map(function(url) {
37-
return { url: url, type: 'variant', time: 0 };
9+
mirrors = uniq(mirrors)
10+
.map(function (url) {
11+
return {url: url, type: 'mirror', time: 0};
3812
});
3913

14+
variants = uniq([])
15+
.map(function (url) {
16+
return {url: url, type: 'variant', time: 0};
17+
});
4018

4119

42-
43-
44-
exports.check = function() {
20+
exports.check = function () {
4521
var backups = [].concat(mirrors, variants);
46-
var promises = backups.map(function(backup) {
22+
var promises = backups.map(function (backup) {
4723
var d1 = new Date();
4824
return request({
49-
url: backup.url,
50-
timeout: 5000
51-
})
52-
.then(function(res) {
25+
url: backup.url,
26+
timeout: 5000
27+
}).then(function () {
5328
var d2 = new Date();
5429
backup.time = d2 - d1;
5530
backup.success = true;
5631
})
57-
.catch(function(err) {
32+
.catch(function (err) {
5833
backup.success = false;
5934
});
60-
})
61-
return promise.all(promises).then(function() {
62-
return backups.filter(function(b) {
63-
return b.success;
64-
}).sort(function(a, b) {
65-
var type = siteType[b.type] - siteType[a.type];
66-
return type == 0 ? a.time - b.time : type;
67-
})
6835
});
36+
37+
return promise.all(promises)
38+
.then(function () {
39+
return backups.filter(function (b) {
40+
return b.success;
41+
}).sort(function (a, b) {
42+
var type = siteType[b.type] - siteType[a.type];
43+
return type == 0 ? a.time - b.time : type;
44+
})
45+
});
6946
};

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"devDependencies": {},
1313
"scripts": {
14-
"test": "echo \"Error: no test specified\" && exit 1"
14+
"test": "node ./test/test.js"
1515
},
1616
"keywords": [
1717
"google",

src/mirrors.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = [
2+
'http://g.jiasubao.co/',
3+
'http://gc.ihuan.me/',
4+
'http://ggss.cf/',
5+
'http://gogoogle.ml/',
6+
'http://google.casejs.com/',
7+
'http://hao.cytbj.com/',
8+
'http://rose.jgoproxy.tk/',
9+
'http://s.8090st.com/',
10+
'http://soguge.com/',
11+
'http://www.wen.lu/',
12+
'http://www.zzq2.com/',
13+
'https://g2.wen.lu/',
14+
'https://gg.kfd.me/',
15+
'https://ggg.eeload.com/',
16+
'https://go.cccyun.cn/',
17+
'https://jisuobuyu.com/',
18+
'https://www.iamgg.pw/',
19+
'https://www.onenew.net/'
20+
];

src/siteType.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
mirror: 2,
3+
variant: 1
4+
};

src/variants.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = [
2+
3+
];

test/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var google = require('../index.js')
1+
var google = require('../index.js');
22

33
google.check()
44
.then(function(arr) {
@@ -7,4 +7,4 @@ google.check()
77
console.log(str);
88
return str;
99
})
10-
})
10+
});

0 commit comments

Comments
 (0)