后台只用cheerio作为后台的jQuery使用
This commit is contained in:
parent
ef68faa337
commit
cdb005306b
|
|
@ -1,18 +1,13 @@
|
|||
var jsdom = require("jsdom");
|
||||
var cheerio = require("cheerio");
|
||||
var fs = require("fs");
|
||||
|
||||
var parsehtml = function(file, callback) {
|
||||
// var html = fs.readFileSync(file).toString();
|
||||
|
||||
fs.readFile(file, (err, data) => {
|
||||
if (err) throw err;
|
||||
var html = data.toString();
|
||||
jsdom.env({
|
||||
html: html,
|
||||
scripts: ["./public/scripts/externe/jquery-3.1.1.min.js"],
|
||||
done: function(errors, window) {
|
||||
var $, anchors, itemdoubleclick, results, allTags, bookmarks;
|
||||
$ = window.$;
|
||||
$ = cheerio.load(html);
|
||||
itemdoubleclick = "";
|
||||
allTags = [];
|
||||
bookmarks = [];
|
||||
|
|
@ -51,9 +46,7 @@ var parsehtml = function(file, callback) {
|
|||
} else {
|
||||
return console.warn("Callback isn't a function.");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = parsehtml;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
"download": "^5.0.3",
|
||||
"express": "~4.13.4",
|
||||
"express-session": "^1.14.1",
|
||||
"jsdom": "^9.10.0",
|
||||
"morgan": "^1.8.1",
|
||||
"multer": "^1.3.0",
|
||||
"mysql": "^2.11.1",
|
||||
|
|
|
|||
Loading…
Reference in New Issue