fix: update taptap topic selector (#5031)

This commit is contained in:
hoilc 2020-06-23 19:18:18 +08:00 committed by GitHub
parent 6e33566000
commit 0851784835
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -18,15 +18,15 @@ module.exports = async (ctx) => {
const $ = cheerio.load(topics_list_data);
const app_img = $('.group-info > a > img').attr('src');
const app_name = $('.breadcrumb > li.active').text();
const app_name = $('.group-detail > h2 > a').first().text();
const label_name = $('.tab-label a.active span').text();
const topics_list = $('.item-content').toArray();
const topics_list = $('.item-content').get();
const parseContent = (htmlString) => {
const $ = cheerio.load(htmlString);
const author = $('.user-name-identity');
const content = $('.topic-content > .bbcode-body');
const content = $('.bbcode-body').first();
const time = $('.topic-update-time').length === 0 ? $('.topic-info [data-dynamic-time]') : $('.topic-update-time [data-dynamic-time]');
const pub_date = time.length === 0 ? new Date() : new Date(time.text().trim());
@ -45,7 +45,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
topics_list.map(async (item) => {
const $ = cheerio.load(item);
const title = $('.item-title > a');
const title = $('.content-text > a').first();
const link = title.attr('href');
const cache = await ctx.cache.get(link);
@ -77,7 +77,7 @@ module.exports = async (ctx) => {
);
ctx.state.data = {
title: `TapTap论坛 ${app_name} - ${label_name}`,
title: `${app_name} - ${label_name} - TapTap论坛`,
link: url,
image: app_img,
item: out.filter((item) => item !== ''),