尊敬的人......
这是我的 node.js 代码... https://gist.github.com/SkyKOG/99d47dbe5a2cec97426b
我试图解析我们考试结果的数据......示例...... http://www.vtualerts.com/results/get_res.php?usn=1MV09IS002&sem=7
我得到了结果......而且我正在往回遍历以前的似乎也是......所有的作品,但遍历发生在随机...... prolly 循环有问题......
json.results = [];
var output = '';
var k = response.query.results.body.div.div[0].table[1].tr.length;
for (var j = 1; j < k; j++) {
for (var i = 0; i <= 5; i++) {
var result_obj = {};
result_obj.subjects = [];
for (key in response.query.results.body.div.div[0].table[1].tr[j].td[i]) {
if (typeof response.query.results.body.div.div[0].table[1].tr[j].td[i].em === "undefined") {
continue;
}
var subject_obj = {};
output += "Subject : " + response.query.results.body.div.div[0].table[1].tr[j].td[i].em + " " + "\n";
var subtext = response.query.results.body.div.div[0].table[1].tr[j].td[i].em + " " + "\n";
subject_obj.subjectname = subtext.replace(/[(].*[)]/, "").trim();
result_obj.subjects.push(subject_obj);
console.log(subject_obj);
break;
}
console.log(result_obj.subjects);
我认为有类似异步概念的东西需要正确实现才能以正确的顺序重新排序 sem...
并以这种格式获取 JSON ... https://gist.github.com/SkyKOG/3845d6a94cea3b744296 我不认为我在正确的范围内推动创建的对象...
请在这方面提供帮助....谢谢...