mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-16 02:42:57 +08:00
route: add 爱思想 aisixiang.com (#1572)
* route: add 爱思想 aisixiang.com * route: add 爱思想排行榜 * docs
This commit is contained in:
46
lib/routes/aisixiang/utils.js
Normal file
46
lib/routes/aisixiang/utils.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
const axios = require('../../utils/axios');
|
||||
const date = require('../../utils/date');
|
||||
|
||||
const ProcessFeed = async (link) => {
|
||||
const id = link
|
||||
.split('/')
|
||||
.pop()
|
||||
.split('.')[0];
|
||||
|
||||
let response = await axios.get(`http://www.aisixiang.com/data/view_json.php?id=${id}`, {
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
|
||||
const description = JSON.parse(iconv.decode(response.data, 'gbk')).content;
|
||||
|
||||
response = await axios.get(`http://www.aisixiang.com${link}`, {
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
|
||||
response.data = iconv.decode(response.data, 'gbk');
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const title = $('.show_text > h3').text();
|
||||
|
||||
const pubDate = date(
|
||||
$('.show_text > .info')
|
||||
.text()
|
||||
.split(':')
|
||||
.pop(),
|
||||
8
|
||||
);
|
||||
|
||||
return {
|
||||
title: title.split('/')[1] || title,
|
||||
author: title.split('/')[0] || '',
|
||||
description,
|
||||
pubDate,
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
ProcessFeed,
|
||||
};
|
||||
Reference in New Issue
Block a user