feat: v3 migration - 3/n
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const routeParams = ctx.params.routeParams;
|
||||
const routeParams = ctx.req.param('routeParams');
|
||||
|
||||
const baseURL = 'https://sourceforge.net';
|
||||
const link = `https://sourceforge.net/directory/?${routeParams.toString()}`;
|
||||
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const itemList = $('ul.projects li[itemprop=itemListElement]');
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('.content h1').text().trim(),
|
||||
link,
|
||||
item: itemList.toArray().map((element) => {
|
||||
@@ -29,5 +29,5 @@ module.exports = async (ctx) => {
|
||||
pubDate,
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user