Add image for anigamer,apkpure and facebook (#1274)

This commit is contained in:
maple 2018-12-12 10:50:54 +08:00 committed by DIYgod
parent 3713d33cae
commit a1e8632d1f
4 changed files with 13 additions and 5 deletions

View File

@ -5,7 +5,7 @@ module.exports = async (ctx) => {
ctx.state.data = {
title: anime.title,
link: `https://ani.gamer.com.tw/animeRef.php?sn=${anime.anime_sn}`,
description: anime.content,
description: `<img src="${anime.cover}"> ` + anime.content.trim(),
item: anime.volumes[0].map((item) => ({
title: `${anime.title}${item.volume}`,
link: `https://ani.gamer.com.tw/animeVideo.php?sn=${item.video_sn}`,

View File

@ -8,11 +8,13 @@ module.exports = async (ctx) => {
let $ = await axios.get(`${prefix}/search?q=${pkg}`).then((r) => cheerio.load(r.data));
const apppage = $('.search-title:nth-child(1)>a').attr('href');
const link = `https://apkpure.com${apppage}/versions`;
console.log(link);
$ = await axios.get(link).then((r) => cheerio.load(r.data));
const img = new URL($('.ver-top img').attr('src'));
img.searchParams.delete('w'); // get full resolution icon
ctx.state.data = {
title: $('.ver-top-h1').text(),
description: $('.ver-top-title>h2').text(),
description: `<img src="${img.href}"> ` + $('.ver-top-title>h2').text(),
link: decodeURI(link),
item: $('.ver li')
.toArray()

View File

@ -10,6 +10,12 @@ module.exports = async (url) => {
.map((i, p) => $(p).text())
.toArray()
.join('\n');
const imgs = $ct
.parent()
.next()
.find('img')
.toArray()
.map((img) => $(img).attr('src'));
const { searchParams: q } = new URL(url);
return { url: `https://www.facebook.com/story.php?story_fbid=${q.get('story_fbid')}&id=${q.get('id')}`, html, title: $($('h3 strong a').get(0)).text(), content };
return { url: `https://www.facebook.com/story.php?story_fbid=${q.get('story_fbid')}&id=${q.get('id')}`, html, title: $($('h3 strong a').get(0)).text(), content, imgs };
};

View File

@ -21,7 +21,7 @@ module.exports = async (ctx) => {
const d = await getArticle('https://mbasic.facebook.com' + url);
return {
title: d.title,
description: d.content.replace(/\n/g, '<br>'),
description: d.imgs.map((u) => `<img src="${u}">`).join('\n') + d.content.replace(/\n/g, '<br>'),
link: d.url,
};
})