-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphantomjs-script.js
29 lines (23 loc) · 967 Bytes
/
phantomjs-script.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
var system = require('system');
var _ = require('partial-js');
var page = require('webpage').create();
page.open('http://pool.skku.edu', function (status) {
try {
if (status) {
var html = page.content;
var result = page.evaluate(function() {
var parseNotice = function (el) {
return { title: el.children[0].innerText, date: el.children[1].innerText };
};
var noticeElList = document.getElementsByClassName('main_notice')[0].querySelectorAll('.main_notice_tr');
var notices = Array.prototype.map.call(noticeElList, parseNotice);
return JSON.stringify(notices);
});
system.stdout.write(result);
};
} catch (err) {
system.stdout.write(err);
}
phantom.exit();
});
// to transform this file into raw js, replace system.stdout.write function to console.log