File lib/HTTPConversation.class.js changed (mode: 100644) (index 88abdbd..63bc9db) |
... |
... |
module.exports = class { |
51 |
51 |
this.debug && console.log(reqURL); |
this.debug && console.log(reqURL); |
52 |
52 |
|
|
53 |
53 |
// With the data all set up, now connect and parse: |
// With the data all set up, now connect and parse: |
54 |
|
let req = https.request(opts, (res) => { |
|
55 |
|
res.headers["set-cookie"] && res.headers["set-cookie"].map((cookie) => { this.jar.setCookieSync(cookie, reqURL); }); |
|
|
54 |
|
let req = https.request(opts, res => { |
|
55 |
|
res.headers["set-cookie"] && res.headers["set-cookie"].map(cookie => { this.jar.setCookieSync(cookie, reqURL); }); |
56 |
56 |
|
|
57 |
57 |
// What to do with incoming data: |
// What to do with incoming data: |
58 |
58 |
let doc = ""; |
let doc = ""; |
59 |
|
res.on("data", (d) => { |
|
|
59 |
|
res.on("data", d => { |
60 |
60 |
this.verbose && console.log("postURLData", d.toString()); |
this.verbose && console.log("postURLData", d.toString()); |
61 |
61 |
if (args.parser) { |
if (args.parser) { |
62 |
62 |
args.parser.parseChunk(d); |
args.parser.parseChunk(d); |
|
... |
... |
module.exports = class { |
71 |
71 |
|
|
72 |
72 |
}); |
}); |
73 |
73 |
|
|
74 |
|
req.on('error', (e) => { |
|
|
74 |
|
req.on('error', e => { |
75 |
75 |
if (this.rejFN && "function" === typeof this.rejFN) |
if (this.rejFN && "function" === typeof this.rejFN) |
76 |
76 |
this.rejFN({ fn: "HC.postURLData", url: reqURL, err: e }); |
this.rejFN({ fn: "HC.postURLData", url: reqURL, err: e }); |
77 |
77 |
else |
else |
|
... |
... |
module.exports = class { |
106 |
106 |
this.debug && console.log(reqURL); |
this.debug && console.log(reqURL); |
107 |
107 |
|
|
108 |
108 |
// With the data all set up, now connect and parse: |
// With the data all set up, now connect and parse: |
109 |
|
let req = https.request(opts, (res) => { |
|
110 |
|
res.headers["set-cookie"] && res.headers["set-cookie"].map((cookie) => { this.jar.setCookieSync(cookie, reqURL); }); |
|
|
109 |
|
let req = https.request(opts, res => { |
|
110 |
|
res.headers["set-cookie"] && res.headers["set-cookie"].map(cookie => { this.jar.setCookieSync(cookie, reqURL); }); |
111 |
111 |
|
|
112 |
112 |
// What to do with incoming data: |
// What to do with incoming data: |
113 |
113 |
let doc = ""; |
let doc = ""; |
114 |
|
res.on("data", (d) => { |
|
|
114 |
|
res.on("data", d => { |
115 |
115 |
this.verbose && console.log("getURL", d.toString()); |
this.verbose && console.log("getURL", d.toString()); |
116 |
116 |
if (args.parser) { |
if (args.parser) { |
117 |
117 |
args.parser.parseChunk(d); |
args.parser.parseChunk(d); |
|
... |
... |
module.exports = class { |
126 |
126 |
|
|
127 |
127 |
}); |
}); |
128 |
128 |
|
|
129 |
|
req.on('error', (e) => { |
|
|
129 |
|
req.on('error', e => { |
130 |
130 |
if (this.rejFN && "function" === typeof this.rejFN) |
if (this.rejFN && "function" === typeof this.rejFN) |
131 |
131 |
this.rejFN({ fn: "HC.getURL", url: reqURL, err: e }); |
this.rejFN({ fn: "HC.getURL", url: reqURL, err: e }); |
132 |
132 |
else |
else |
File lib/OdysseyInfo.class.js changed (mode: 100644) (index fa6c951..7a27705) |
... |
... |
function getCaseIDParser(oiObj, callback, errFN) { |
29 |
29 |
let handler = new DomHandler((err, dom) => { |
let handler = new DomHandler((err, dom) => { |
30 |
30 |
if (err) { |
if (err) { |
31 |
31 |
errFN && "function" === typeof errFN && errFN({ msg: "caseIDParser", err: err }); |
errFN && "function" === typeof errFN && errFN({ msg: "caseIDParser", err: err }); |
|
32 |
|
return; |
32 |
33 |
} else { |
} else { |
33 |
34 |
// Find the containing node: |
// Find the containing node: |
34 |
|
let idLinks = du.filter((node) => { |
|
|
35 |
|
let idLinks = du.filter(node => { |
35 |
36 |
return ("a" === node.name && "caseLink" === node.attribs.class); |
return ("a" === node.name && "caseLink" === node.attribs.class); |
36 |
37 |
}, dom); |
}, dom); |
37 |
38 |
|
|
38 |
39 |
if (1 !== idLinks.length) { |
if (1 !== idLinks.length) { |
39 |
40 |
errFN && "function" === typeof errFN && errFN({ msg: "caseIDParser: unable to find caseID", html: du.getOuterHTML(dom) }); |
errFN && "function" === typeof errFN && errFN({ msg: "caseIDParser: unable to find caseID", html: du.getOuterHTML(dom) }); |
|
41 |
|
return; |
40 |
42 |
} |
} |
41 |
43 |
|
|
42 |
44 |
try { |
try { |
|
... |
... |
function getCaseInfoParser(oiObj, callback, errFN) { |
63 |
65 |
let handler = new DomHandler((err, dom) => { |
let handler = new DomHandler((err, dom) => { |
64 |
66 |
if (err) { |
if (err) { |
65 |
67 |
errFN && "function" === typeof errFN && errFN({ msg: "caseInfoParser", err: err }); |
errFN && "function" === typeof errFN && errFN({ msg: "caseInfoParser", err: err }); |
|
68 |
|
return; |
66 |
69 |
} else { |
} else { |
67 |
70 |
oiObj.debug && console.log("Finding party info"); |
oiObj.debug && console.log("Finding party info"); |
68 |
71 |
|
|
69 |
72 |
// Find the containing node: |
// Find the containing node: |
70 |
|
let partyInfo = du.filter((node) => { |
|
|
73 |
|
let partyInfo = du.filter(node => { |
71 |
74 |
return ("div" === node.name && "divPartyInformation_body" === node.attribs.id); |
return ("div" === node.name && "divPartyInformation_body" === node.attribs.id); |
72 |
75 |
}, dom); |
}, dom); |
73 |
76 |
|
|
74 |
77 |
if (1 !== partyInfo.length) { |
if (1 !== partyInfo.length) { |
75 |
78 |
errFN && "function" === typeof errFN && errFN({ msg: "caseIDParser: unable to find party info", oi: oiObj }); |
errFN && "function" === typeof errFN && errFN({ msg: "caseIDParser: unable to find party info", oi: oiObj }); |
|
79 |
|
return; |
76 |
80 |
} |
} |
77 |
81 |
|
|
78 |
82 |
// Each party is in a <div class="col-md-8"/> |
// Each party is in a <div class="col-md-8"/> |
79 |
|
let partyDivs = du.filter((node) => { |
|
|
83 |
|
let partyDivs = du.filter(node => { |
80 |
84 |
return ("div" === node.name && "col-md-8" === node.attribs.class); |
return ("div" === node.name && "col-md-8" === node.attribs.class); |
81 |
85 |
}, partyInfo); |
}, partyInfo); |
82 |
86 |
|
|
83 |
87 |
// Each of those has a <p><span>class</span>name</p> and <p>Address</p>: |
// Each of those has a <p><span>class</span>name</p> and <p>Address</p>: |
84 |
88 |
oiObj.parties = []; |
oiObj.parties = []; |
85 |
|
partyDivs.forEach((partyDiv) => { |
|
|
89 |
|
partyDivs.forEach(partyDiv => { |
86 |
90 |
let party = {}; |
let party = {}; |
87 |
|
let pDivs = du.filter((node) => { |
|
|
91 |
|
let pDivs = du.filter(node => { |
88 |
92 |
return ("p" === node.name); |
return ("p" === node.name); |
89 |
93 |
}, partyDiv); |
}, partyDiv); |
90 |
94 |
|
|
91 |
95 |
// pDivs[0]: <p><span>class</span>name</p> |
// pDivs[0]: <p><span>class</span>name</p> |
92 |
|
du.filter((node) => { |
|
|
96 |
|
du.filter(node => { |
93 |
97 |
return ("span" === node.name); |
return ("span" === node.name); |
94 |
|
}, pDivs[0]).forEach((span) => { |
|
|
98 |
|
}, pDivs[0]).forEach(span => { |
95 |
99 |
// SHOULD only be ONE of these: |
// SHOULD only be ONE of these: |
96 |
|
party.role = du.filter((node) => { |
|
|
100 |
|
party.role = du.filter(node => { |
97 |
101 |
return ("text" === node.type); |
return ("text" === node.type); |
98 |
|
}, span).map((val) => { |
|
|
102 |
|
}, span).map(val => { |
99 |
103 |
return val.data; |
return val.data; |
100 |
104 |
}).join(" ").trim(); |
}).join(" ").trim(); |
101 |
105 |
// Get rid of the span for the next manipulation: |
// Get rid of the span for the next manipulation: |
102 |
106 |
du.removeElement(span); |
du.removeElement(span); |
103 |
107 |
}); |
}); |
104 |
|
party.name = du.filter((node) => { |
|
|
108 |
|
party.name = du.filter(node => { |
105 |
109 |
return ("text" === node.type); |
return ("text" === node.type); |
106 |
|
}, pDivs[0]).map((val) => { |
|
|
110 |
|
}, pDivs[0]).map(val => { |
107 |
111 |
return val.data; |
return val.data; |
108 |
112 |
}).join(" ").trim(); |
}).join(" ").trim(); |
109 |
113 |
|
|
110 |
114 |
// pDivs[1]: Address |
// pDivs[1]: Address |
111 |
115 |
if (pDivs[1]) { |
if (pDivs[1]) { |
112 |
116 |
try { |
try { |
113 |
|
party.address = du.filter((node) => { |
|
|
117 |
|
party.address = du.filter(node => { |
114 |
118 |
return ("text" === node.type); |
return ("text" === node.type); |
115 |
|
}, pDivs[1]).map((val) => { |
|
|
119 |
|
}, pDivs[1]).map(val => { |
116 |
120 |
return val.data; |
return val.data; |
117 |
121 |
}); |
}); |
118 |
122 |
} catch (e) { |
} catch (e) { |
File updateAddress.js changed (mode: 100644) (index 5c47ea9..8e0bfad) |
... |
... |
const Case = require("./lib/Case.class"); |
21 |
21 |
const OdysseyInfo = require("./lib/OdysseyInfo.class"); |
const OdysseyInfo = require("./lib/OdysseyInfo.class"); |
22 |
22 |
|
|
23 |
23 |
let opts = require("./creds")["SQLITE3"]; |
let opts = require("./creds")["SQLITE3"]; |
24 |
|
opts.connectCallback = (database) => { |
|
|
24 |
|
opts.connectCallback = database => { |
25 |
25 |
// Prep the databse to update each case as we get its updated info: |
// Prep the databse to update each case as we get its updated info: |
26 |
26 |
let pDao = new DAO.PartyCtlr(database); |
let pDao = new DAO.PartyCtlr(database); |
27 |
27 |
pDao.stmts.update = pDao.prepare( |
pDao.stmts.update = pDao.prepare( |
|
... |
... |
opts.connectCallback = (database) => { |
76 |
76 |
Promise.all(promises) |
Promise.all(promises) |
77 |
77 |
.finally(() => { |
.finally(() => { |
78 |
78 |
// Shut down the database, and the HTTPS agent: |
// Shut down the database, and the HTTPS agent: |
79 |
|
require("./lib/httpOptions").getGlobalAgent().destroy(); |
|
80 |
79 |
pDao.finalize(); |
pDao.finalize(); |
81 |
80 |
cDao.finalize(); |
cDao.finalize(); |
82 |
81 |
DAO.disconnect(database); |
DAO.disconnect(database); |
|
82 |
|
require("./lib/httpOptions").getGlobalAgent().destroy(); |
83 |
83 |
}) |
}) |
84 |
84 |
; |
; |
85 |
85 |
} |
} |