diff --git a/lib/v2/luogu/daily.js b/lib/v2/luogu/daily.js index 39b558b4faa91a..4e8afb5a3efc7c 100644 --- a/lib/v2/luogu/daily.js +++ b/lib/v2/luogu/daily.js @@ -9,19 +9,24 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); const title = $('head title').text(); - const firstPost = $('.am-comment-main .am-comment-bd').first(); - const dailyLink = firstPost.find('a').first().attr('href'); - const issueHeading = firstPost.find('h1').text().trim(); + const injectionScript = $('head script:contains("window._feInjection")').text(); + const jsonRaw = injectionScript.match(/window\._feInjection = JSON\.parse\(decodeURIComponent\("(.*?)"\)\);/)[1]; + const jsonDecode = JSON.parse(decodeURIComponent(jsonRaw)); + + const mdRaw = jsonDecode.currentData.post.content; + + const dailyLink = mdRaw.match(/<([^>]*)>/)[1]; const { data: dailyResponse } = await got(dailyLink); const $daily = cheerio.load(dailyResponse); + const issueHeading = $daily('.am-article-title').first().text().trim(); const item = [ { title, description: $daily('#article-content').html(), link, - author: firstPost.find('p').eq(1).text(), + author: jsonDecode.currentData.post.author.name, guid: `${link}#${issueHeading}`, - pubDate: parseDate(issueHeading.match(/(\d{4} 年 \d{1,2} 月 \d{1,2} 日)/)[1], 'YYYY 年 M 月 D 日'), + pubDate: parseDate(jsonDecode.currentData.post.time), }, ];