-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrap.html
148 lines (132 loc) · 4.42 KB
/
scrap.html
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
</head>
<body>
<script>
var powerList = "";
var count = 0;
var inputNames = {
businessName: "ctl00$ContentPlaceHolderMainContent$businessInfo$businessName",
dba: "ctl00$ContentPlaceHolderMainContent$businessInfo$dba",
address: "ctl00$ContentPlaceHolderMainContent$businessInfo$address",
entity: "ctl00$ContentPlaceHolderMainContent$businessInfo$entity",
city: "ctl00$ContentPlaceHolderMainContent$businessInfo$city",
state: "ctl00$ContentPlaceHolderMainContent$businessInfo$state",
zip: "ctl00$ContentPlaceHolderMainContent$businessInfo$zip",
phoneNo: "ctl00$ContentPlaceHolderMainContent$businessInfo$phoneNo"
}
var errMsg = "ctl00_ContentPlaceHolderMainContent_lblLicenseNoOrAppFeeNumberNotFoundMessage";
var indemnitorId = "ctl00_ContentPlaceHolderMainContent_indemnitorInfo_radioButtonListChooseIndemnitor";
var jobClass = "span_radioButtonListChooseIndemnitor_Titles";
var table = "ctl00_ContentPlaceHolderMainContent_classificationInfo_dataListClassification";
var keys = Object.keys(inputNames);
var errors = [];
function getSingle(license, s, callback){
$.ajax({
url: "https://www.bondapp.com/services/v3/BondApplication/Default.aspx?id=2&m=0&license=" + license,
method: "get",
success: function(res) {
if ($(res).find('#' + errMsg).get().length === 0) {
if ($($(res).find(".table_webUserControl [name=" + inputNames.businessName + "]").get()[0]).val() == 'undefined')
{
errors.push(license);
} else {
var names = $(res).find('#' + indemnitorId + ' input').get();
var jobs = $(res).find('.' + jobClass).get();
var single = license + ',';
keys.forEach(function(k){
var name = inputNames[k];
var val = $($(res).find(".table_webUserControl [name=" + name + "]").get()[0]).val();
if (k === 'entity') {
single += $($(res).find(".table_webUserControl [name=" + name + "]" + " option[value=" + val + "]").get()[0]).html() + ',';
} else {
single += val + ',';
}
});
var classfications = $(res).find('#' + table + ' div span').get();
single += '"';
for (var j = 0; j < classfications.length; j = j + 2) {
if (j == classfications.length - 2)
single += $(classfications[j]).html() + ' ' + $(classfications[j + 1]).html();
else
single += $(classfications[j]).html() + ' ' + $(classfications[j + 1]).html() + '\n';
}
single += '",';
if (names.length < 2) {
powerList += single + ',,,,,,,\n';
} else {
for (var i = 0; i < names.length - 1; i++) {
var _single = single;
var name = $(names[i]).val();
var _names = name.split(':');
for (var j = 0; j < 3; j++) {
if (_names[j]) {
_single += _names[j] + ',';
} else {
_single += ',';
}
}
var job = $(jobs[i]).html();
job = job.replace("(", "");
job = job.replace(")", "");
_single += job;
_single += ',,,,,\n';
powerList += _single;
}
}
}
}
count--;
if (count === 0 && errors.length > 0) {
var _errors = errors;
errors = [];
count = _errors.length;
_errors.forEach(license => {
getSingle(license, s, callback);
});
} else if (count === 0 && errors.length === 0) {
if (callback === 'none') {
alert('die');
} else {
callback(s);
}
}
},
error: function(err) {
errors.push(license);
count--;
if (count === 0 && errors.length > 0) {
var _errors = errors;
errors = [];
count = _errors.length;
_errors.forEach(license => {
getSingle(license, s, callback);
});
}
}
});
}
function getRange(s) {
setTimeout(function() {
console.log('getRange');
if (s + step >= end) {
count = end - s + 1;
for (var i = s; i <= end; i++) {
getSingle(i, s + step, 'none');
}
} else {
count = step;
for (var i = s; i < (s + step); i++) {
getSingle(i, s + step, getRange);
}
}
}, 2000);
}
var start = 900000;
var end = 900100;
var step = 5;
getRange(start);
</script>
</body>
</html>