⽬标是将task1-5中的所有题⽬、以及答案提取出来,以⽂本形式保存。最终提取出的效果如下。
Task 1: You will be given 10 minutes to read the text for the first time and then choose an appropriate answer for each of the following qu
1. What’s the passage mainly about?
A. How to learn online successfully.
B. How to set up a learning goal.
C. The future of online learning.
D. The benefits of online learning.
...
这是答案⽂本:
var fs = require('fs');
var cheerio = require('cheerio');
var myHtml = fs.readFileSync("a.html"); var $ = cheerio.load(myHtml);
var t = $('html').find('hr');
var t2 = t.nextAll();
t2.each(function(i, elem) {
getContent($(this));
console.log($(this).text());
});
var fs = require('fs');
var cheerio = require('cheerio');
var iconv = require('iconv-lite');
var myHtml = fs.readFileSync("a.html");
var $ = cheerio.load(iconv.decode(myHtml, 'gbk')); var t = $('html').find('hr');
var t2 = t.nextAll();
t2.each(function(i, elem) {
getContent($(this));
console.log($(this).text());
});
function getContent(node){
var a = ts();
if (a.length == 0) {
if (node.is('br')){
RST+='\n';
} else {
RST+=().trim();;
}
} else {
});
if (node.is('p') || node.is('tr')){
RST+='\n';
}
}
}
<SCRIPT LANGUAGE="JavaScript"> var StandardAnswer = new Array()
nodeselectorStandardAnswer =["C","D","D","D","D"] </SCRIPT>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论