* refactor: fix all get * fix(utils/common-config): charset case compare * Revert "fix(utils/common-config): charset case compare" This reverts commit 3c1880f2fad53ad2cafddcee7741390fd46fa3d2. * fix: nga * fix: notateslaapp * fix: ps * fix: xjtu * fix: enforce error on restricted syntax for get calls * fix: eslint * fix: more eslint
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { Route } from '@/types';
|
|
import got from '@/utils/got';
|
|
import * as cheerio from 'cheerio';
|
|
|
|
export const route: Route = {
|
|
path: '/newest',
|
|
categories: ['programming'],
|
|
example: '/blogread/newest',
|
|
radar: [
|
|
{
|
|
source: ['blogread.cn/news/newest.php'],
|
|
},
|
|
],
|
|
name: '最新文章',
|
|
maintainers: ['fashioncj'],
|
|
handler,
|
|
};
|
|
|
|
async function handler() {
|
|
const url = 'https://blogread.cn/news/newest.php';
|
|
const response = await got({
|
|
method: 'get',
|
|
url,
|
|
});
|
|
const $ = cheerio.load(response.data);
|
|
const resultItem = $('.media')
|
|
.toArray()
|
|
.map((elem) => {
|
|
elem = $(elem);
|
|
const $link = elem.find('dt a');
|
|
return {
|
|
title: $link.text(),
|
|
description: elem.find('dd').eq(0).text(),
|
|
link: $link.attr('href'),
|
|
author: elem.find('.small a').eq(0).text(),
|
|
pubDate: elem.find('dd').eq(1).text().split('\n')[2],
|
|
};
|
|
});
|
|
return {
|
|
title: '技术头条',
|
|
link: url,
|
|
item: resultItem,
|
|
};
|
|
}
|