mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
Hotfix: dajia (#1709)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const axios = require('../../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const listRes = await axios({
|
||||
@@ -13,15 +14,17 @@ module.exports = async (ctx) => {
|
||||
const storyList = JSON.parse(listRes.data.slice(1, -2)).data;
|
||||
const resultItem = await Promise.all(
|
||||
storyList.map(async (story) => {
|
||||
const url = story.n_mobile_url;
|
||||
const mobileUrl = story.n_mobile_url;
|
||||
const pcUrl = story.n_url;
|
||||
const item = {
|
||||
title: story.n_title,
|
||||
description: '',
|
||||
link: url,
|
||||
link: pcUrl,
|
||||
guid: mobileUrl,
|
||||
author: story.name,
|
||||
pubDate: new Date(story.n_publishtime).toUTCString(),
|
||||
};
|
||||
const key = `tx-dajia: ${url}`;
|
||||
const key = `tx-dajia: ${mobileUrl}`;
|
||||
const value = await ctx.cache.get(key);
|
||||
|
||||
if (value) {
|
||||
@@ -29,13 +32,13 @@ module.exports = async (ctx) => {
|
||||
} else {
|
||||
const storyDetail = await axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
url: pcUrl,
|
||||
headers: {
|
||||
Referer: url,
|
||||
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
|
||||
Referer: pcUrl,
|
||||
},
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
const $ = cheerio.load(storyDetail.data);
|
||||
const $ = cheerio.load(iconv.decode(storyDetail.data, 'gb2312'));
|
||||
$('#articleContent img').each(function(_, item) {
|
||||
const $img = $(item);
|
||||
const src = $img.attr('src');
|
||||
|
||||
Reference in New Issue
Block a user