工作
本周修复了线上系统的一些问题,算是顺利上线了。线上碰到一个棘手的问题,暂时还没有方案;
我们的小程序中嵌套的webView,总是无法及时跟新,存在缓存。需要在微信中清除缓存才能正常使用。看看后续有没有办法解决。
摸鱼的时候写了个脚本去爬小说 gitee.com/liuxin2018/…
关键代码
const superagent = require("superagent");
const cheerio = require("cheerio");
const fs = require("fs");
const goodsList = [];
const url = "https://1fb2629a2564999eea.bqgeu.com/book/157698/list.html";
const baseUrl = "https://1fb2629a2564999eea.bqgeu.com";
const maxArt = 100; // 每条啊最大的文章数量
superagent.get(url).end((err, data) => {
if (err) return console.log("爬取页面失败");
// data.text 就是整个页面文件
parseData(data.text);
});
function parseData(page) {
const $ = cheerio.load(page);
$(".book_last dd").each((index, item) => {
const obj = {
goods_url: $(item).find("a").prop("href"),
goods_title: $(item).find("a").text(),
};
if (obj.goods_url == "#footer") {
return;
}
goodsList.push(obj);
});
写入txt
fs.writeFile("./html/article" + i + ".html", string, () =>
console.log("写入完成:article" + i + ".html")
);
为了解决部门产品经理不作为的问题,我们前端整理了一套需求开发规范,准备在部门内部推行。下周看看推行结果