forked from domnantas/ham.guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrapeDXCC.js
42 lines (39 loc) · 1013 Bytes
/
scrapeDXCC.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
const rp = require('request-promise');
const cheerio = require('cheerio');
const fs = require('fs');
const options = {
uri: `http://ut7ut.com/index.php/dxcc-countries-list/`,
transform: function(body) {
return cheerio.load(body);
}
};
rp(options)
.then(function($) {
let data = $('#tablepress-DXCC tbody tr')
.map((i, el) => ({
prefix: $(el)
.children('.column-1')
.text(),
name: $(el)
.children('.column-2')
.text(),
continent: $(el)
.children('.column-3')
.text(),
ituZone: $(el)
.children('.column-4')
.text(),
cqZone: $(el)
.children('.column-5')
.text(),
note: $(el)
.children('.column-6')
.text()
}))
.get();
fs.writeFileSync('ARManual/.vuepress/data/dxcc.json', JSON.stringify(data, null, 2));
console.log("Scraped DXCC successfuly");
})
.catch(function(err) {
console.log(err);
});