-
Notifications
You must be signed in to change notification settings - Fork 917
/
pull.js
77 lines (67 loc) · 2.01 KB
/
pull.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
var provinceNode = document.querySelectorAll("p.MsoNormal b span");
var provinceArray = [];
provinceNode.forEach(function(i, index){
var length = provinceArray.length;
if(length === 0){
provinceArray.push({
"id": i.outerText.trim(),
"name": ''
})
}else if(!provinceArray[length-1].name){
if(i.outerText.trim()){
provinceArray[length-1].name = i.outerText.trim();
}
}else {
if(i.outerText.trim()){
provinceArray.push({
"id": i.outerText.trim(),
"name": ''
})
}
}
});
var cityNode = document.querySelectorAll("p.MsoNormal>span");
var cityArray = [];
cityNode.forEach(function(i, index){
var length = cityArray.length;
if(length === 0){
if (i.outerText.trim()){
cityArray.push({
"id": i.outerText.trim(),
"name": ''
})
}
}else if(!cityArray[length-1].name){
if(i.outerText.trim()){
cityArray[length-1].name = i.outerText.trim();
}
}else {
if(i.outerText.trim()){
cityArray.push({
"id": i.outerText.trim(),
"name": ''
})
}
}
});
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
if(typeof data === "object"){
data = JSON.stringify(data, undefined, 4)
}
var blob = new Blob([data], {type: 'text/json'}),
e = document.createEvent('MouseEvents'),
a = document.createElement('a')
a.download = filename
a.href = window.URL.createObjectURL(blob)
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':')
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
a.dispatchEvent(e)
}
})(console)
console.save(JSON.stringify(cityArray), 'city.json')