-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscrape.js
More file actions
45 lines (36 loc) · 1.44 KB
/
Copy pathscrape.js
File metadata and controls
45 lines (36 loc) · 1.44 KB
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
var
fs = require('fs'),
fetch = require('node-fetch'),
striptags = require('striptags'),
jsdom = require('jsdom'),
table2json = require('./table2json');
var clean = data => {
data.forEach( d => {
delete d.Graphic;
d.Character = d['\n Character \n \n If these characters are not displaying correctly, click for information.\n \n '];
delete d['\n Character \n \n If these characters are not displaying correctly, click for information.\n \n '];
d['Unicode Name'] = striptags(d['Unicode Name']);
d.Character = striptags(d.Character);
d['USV'] = striptags(d['USV']);
})
return data;
}
var save = data => {
fs.writeFile("./ipaBook.json", JSON.stringify(data,null,2), function(err) {
if(err) {
return console.log(err);
}
console.log("Data saved to ipaBook.json");
});
}
var parse = data => {
jsdom.env(data, function(err, window){
var table = window.document.querySelector('table.Table_Default');
var data = table2json.parse(table);
save(clean(data));
})
}
var xparse = function(data){ console.log(data) }
fetch('http://scriptsource.org/cms/scripts/page.php?item_id=entry_detail&uid=wlbaybzb9e#bce6a902')
.then(response => response.text())
.then(parse)