修复煎蛋的图片解析 (#1917)

This commit is contained in:
Kyle Wang 2019-04-13 14:28:33 +08:00 committed by DIYgod
parent 9ff646c066
commit 4d96d1cbd0
1 changed files with 3 additions and 10 deletions

View File

@ -1,10 +1,6 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
const base64_decode = (i) => Buffer.from(i, 'base64').toString('binary');
// jandan_decode is borrowed from jandan.net, which is used in function jandan_load_img.
const jandan_decode = (m) => base64_decode(m);
const baseUrl = 'http://jandan.net/';
module.exports = async (ctx) => {
@ -35,21 +31,18 @@ module.exports = async (ctx) => {
const imgList = [];
$(item)
.find('.text .img-hash')
.find('.view_img_link')
.each((_, item) => {
const imgUrl = $(item).html();
const imgUrl = $(item).attr('href');
if (imgUrl !== undefined) {
imgList.push(jandan_decode(imgUrl).replace(/(\/\/\w+\.sinaimg\.cn\/)(\w+)(\/.+\.(gif|jpg|jpeg))/, '$1large$3'));
imgList.push(imgUrl);
}
});
if (imgList.length === 0) {
return;
}
$(item)
.find('.img-hash')
.remove();
const text =
$(item)
.find('.text p')