mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: v3 migration - 2/n
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { art } = require('@/utils/render');
|
||||
import { load } from 'cheerio';
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
|
||||
const { suffix = 'c100028/common_xq_list.shtml' } = ctx.params;
|
||||
const link = `${baseUrl}/csrc/${suffix}`;
|
||||
const { data: res } = await got(link);
|
||||
const $ = cheerio.load(res);
|
||||
const $ = load(res);
|
||||
|
||||
const channelId = $('meta[name="channelid"]').attr('content');
|
||||
|
||||
@@ -52,7 +52,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: res } = await got(item.link);
|
||||
const $ = cheerio.load(res);
|
||||
const $ = load(res);
|
||||
item.description = $('.detail-news').html();
|
||||
return item;
|
||||
})
|
||||
@@ -60,10 +60,10 @@ module.exports = async (ctx) => {
|
||||
);
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `中国证券监督管理委员会 - ${data?.data.channelName || $('head title').text()}`,
|
||||
link,
|
||||
image: 'http://www.csrc.gov.cn/favicon.ico',
|
||||
item: out,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
const cheerio = require('cheerio');
|
||||
import { load } from 'cheerio';
|
||||
const { host, puppeteerGet } = require('./utils');
|
||||
const config = require('@/config').value;
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import { config } from '@/config';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
import puppeteer from '@/utils/puppeteer';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { gchannel = 'paimai' } = ctx.params;
|
||||
@@ -24,13 +25,13 @@ module.exports = async (ctx) => {
|
||||
break;
|
||||
}
|
||||
|
||||
const browser = await require('@/utils/puppeteer')({ stealth: true });
|
||||
const browser = puppeteer({ stealth: true });
|
||||
|
||||
const list = await ctx.cache.tryGet(
|
||||
link,
|
||||
async () => {
|
||||
const response = await puppeteerGet(link, browser);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const list = $('[class^="conList_ul"] li')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
@@ -51,7 +52,7 @@ module.exports = async (ctx) => {
|
||||
list.map((info) =>
|
||||
ctx.cache.tryGet(info.link, async () => {
|
||||
const response = await puppeteerGet(info.link, browser);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
let date;
|
||||
|
||||
$('.easysite-news-operation').remove();
|
||||
@@ -72,9 +73,9 @@ module.exports = async (ctx) => {
|
||||
|
||||
browser.close();
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `中国海关-${channelName}`,
|
||||
link,
|
||||
item: out,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { category = 'gjlckjdjt' } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
|
||||
|
||||
const rootUrl = 'http://www.forestry.gov.cn';
|
||||
const currentUrl = new URL(`${category}.jhtml`, rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
let items = $('a.items')
|
||||
.slice(0, limit)
|
||||
@@ -43,7 +43,7 @@ module.exports = async (ctx) => {
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
|
||||
content('p').each((_, e) => {
|
||||
e = content(e);
|
||||
@@ -81,7 +81,7 @@ module.exports = async (ctx) => {
|
||||
|
||||
const icon = new URL('favicon.ico', rootUrl).href;
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
@@ -92,5 +92,5 @@ module.exports = async (ctx) => {
|
||||
subtitle: $('div.weizhi').contents().last().text(),
|
||||
author: '国家林业和草原局',
|
||||
allowEmpty: true,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -35,10 +35,11 @@
|
||||
// await gdgov(info, ctx);
|
||||
// };
|
||||
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { art } from '@/utils/render';
|
||||
|
||||
const gdgov = async (info, ctx) => {
|
||||
const path = ctx.path.split('/').filter((item) => item !== '');
|
||||
@@ -116,7 +117,7 @@ const gdgov = async (info, ctx) => {
|
||||
} else {
|
||||
const res = await got(currentUrl);
|
||||
const dataArray = res.data;
|
||||
$ = cheerio.load(dataArray);
|
||||
$ = load(dataArray);
|
||||
switch (name_match_type) {
|
||||
case 'name':
|
||||
name = name_element;
|
||||
@@ -168,8 +169,6 @@ const gdgov = async (info, ctx) => {
|
||||
// http://fgj.maoming.gov.cn/zcjdpt?id=4993
|
||||
// https://zcjd.cloud.gd.gov.cn/api/home/article?id=4993
|
||||
return ctx.cache.tryGet(link, async () => {
|
||||
const { art } = require('@/utils/render');
|
||||
|
||||
const zcjdlink = 'https://zcjd.cloud.gd.gov.cn/api/home/article' + idlink.search;
|
||||
const response = await got(zcjdlink);
|
||||
const data = response.data.data;
|
||||
@@ -192,7 +191,7 @@ const gdgov = async (info, ctx) => {
|
||||
return ctx.cache.tryGet(link, async () => {
|
||||
// 获取网页
|
||||
const { data: res } = await got(link);
|
||||
const content = cheerio.load(res);
|
||||
const content = load(res);
|
||||
|
||||
// 获取来源
|
||||
let author = '';
|
||||
@@ -224,11 +223,11 @@ const gdgov = async (info, ctx) => {
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: name,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
import got from '@/utils/got';
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const rootUrl = 'http://www.tqyb.com.cn';
|
||||
|
||||
@@ -29,9 +29,9 @@ module.exports = async (ctx) => {
|
||||
guid: timezone(parseDate(item.datetime, 'YYYY年MM月DD日 HH:mm'), +8) + item.cname + item.sigtypename,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '广东省内城市预警信号',
|
||||
link: `http://www.tqyb.com.cn/gz/weatherAlarm/otherCity/`,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
import got from '@/utils/got';
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const rootUrl = 'http://www.tqyb.com.cn';
|
||||
|
||||
@@ -22,9 +22,9 @@ module.exports = async (ctx) => {
|
||||
guid: parseDate(item.ddate) + item.title,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '突发性天气提示',
|
||||
link: 'http://www.tqyb.com.cn/gz/weatherAlarm/suddenWeather/',
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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';
|
||||
|
||||
const rootUrl = 'https://www.gz.gov.cn';
|
||||
|
||||
@@ -12,11 +12,11 @@ const urlMap = {
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const channel = ctx.params.channel;
|
||||
const category = ctx.params.category;
|
||||
const channel = ctx.req.param('channel');
|
||||
const category = ctx.req.param('category');
|
||||
const url = `${rootUrl}/${channel}/${urlMap[category]}/`;
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
const items = $('.news_list li')
|
||||
.toArray()
|
||||
@@ -30,9 +30,9 @@ module.exports = async (ctx) => {
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `广州市人民政府 - ${$('.main_title').text()}`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
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 category = ctx.params.category ?? 'gzdt';
|
||||
const category = ctx.req.param('category') ?? 'gzdt';
|
||||
|
||||
const rootUrl = 'http://czt.hebei.gov.cn';
|
||||
const currentUrl = `${rootUrl}/xwdt/${category}`;
|
||||
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
let items = $('td li a[title]')
|
||||
.toArray()
|
||||
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
item.author = content('meta[name="ContentSource"]').attr('content');
|
||||
item.pubDate = parseDate(content('meta[name="PubDate"]').attr('content'));
|
||||
@@ -45,9 +45,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const rootURL = 'http://www.huizhou.gov.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const cate = ctx.params.category ?? 'zwyw';
|
||||
const cate = ctx.req.param('category') ?? 'zwyw';
|
||||
const url = `${rootURL}/zwgk/hzsz/${cate}`;
|
||||
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const title = $('span#navigation').children('a').last().text();
|
||||
const list = $('ul.ul_art_row')
|
||||
.map((_, item) => ({
|
||||
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
try {
|
||||
item.description = content('div.artContent').html();
|
||||
@@ -50,9 +50,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `惠州市人民政府 - ${title}`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
const baseUrl = 'http://wlwz.changsha.gov.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
|
||||
responseType: 'buffer',
|
||||
});
|
||||
listPage.data = iconv.decode(listPage.data, 'gbk');
|
||||
const $ = cheerio.load(listPage.data);
|
||||
const $ = load(listPage.data);
|
||||
const list = $('.table1 tbody tr')
|
||||
.slice(1)
|
||||
.map((_, tr) => {
|
||||
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
|
||||
responseType: 'buffer',
|
||||
});
|
||||
postPage.data = iconv.decode(postPage.data, 'gbk');
|
||||
const $ = cheerio.load(postPage.data);
|
||||
const $ = load(postPage.data);
|
||||
|
||||
const data = {
|
||||
title: item.title,
|
||||
@@ -44,9 +44,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '来信反馈 - 长沙市市长信箱',
|
||||
link: `${baseUrl}/webapp/cs2020/email/index.jsp`,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const url = 'https://immi.homeaffairs.gov.au/_layouts/15/api/Data.aspx/GetNews';
|
||||
|
||||
@@ -34,10 +34,10 @@ module.exports = async (ctx) => {
|
||||
link: getItemUrl(item.Id),
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: 'News - Immigration and Citizenship',
|
||||
link: 'https://immi.homeaffairs.gov.au/news-media/archive',
|
||||
description: 'Australia Government, Department of Home Affairs',
|
||||
item: list,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
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 { id = 'sytzgg' } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
|
||||
|
||||
const rootUrl = 'http://www.jgjcndrc.org.cn';
|
||||
const currentUrl = new URL(`list.aspx?clmId=${id}`, rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
let items = $('ul.list_02 li.li a[title]')
|
||||
.slice(0, limit)
|
||||
@@ -31,7 +31,7 @@ module.exports = async (ctx) => {
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
|
||||
item.title = content('div.txt_title1').text();
|
||||
item.description = content('div#zoom').html();
|
||||
@@ -46,7 +46,7 @@ module.exports = async (ctx) => {
|
||||
const subtitle = $('li.L').first().text();
|
||||
const image = new URL($('img.logo2').prop('src'), rootUrl).href;
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: `${author} - ${subtitle}`,
|
||||
link: currentUrl,
|
||||
@@ -55,5 +55,5 @@ module.exports = async (ctx) => {
|
||||
image,
|
||||
subtitle,
|
||||
author,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://jnmhc.jinan.gov.cn';
|
||||
@@ -18,11 +18,11 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(res.data, { xmlMode: true });
|
||||
const $ = load(res.data, { xmlMode: true });
|
||||
|
||||
const list = $('record');
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '济南卫建委-执业考试通知',
|
||||
link: `${baseUrl}/col/col14418/index.html`,
|
||||
item: list
|
||||
@@ -31,7 +31,7 @@ module.exports = async (ctx) => {
|
||||
item = $(item).text();
|
||||
|
||||
// 解析上一步中的html
|
||||
const html = cheerio.load(item);
|
||||
const html = load(item);
|
||||
|
||||
const title = html('td[width="620"] a').attr('title');
|
||||
const link = html('td[width="620"] a').attr('href');
|
||||
@@ -45,5 +45,5 @@ module.exports = async (ctx) => {
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const host = 'http://www.maonan.gov.cn';
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
|
||||
let id = '';
|
||||
let name = '';
|
||||
|
||||
switch (ctx.params.category) {
|
||||
switch (ctx.req.param('category')) {
|
||||
case 'zwgk':
|
||||
id = 'zwgk';
|
||||
name = '政务公开';
|
||||
@@ -42,7 +42,7 @@ module.exports = async (ctx) => {
|
||||
|
||||
const res = await got(`${host}/${id}/`);
|
||||
const dataArray = res.data;
|
||||
const $ = cheerio.load(dataArray);
|
||||
const $ = load(dataArray);
|
||||
const list = $('li.clearfix a[href*="www.maonan.gov.cn"], li.clearfix a[href*="mp.weixin.qq.com"]');
|
||||
|
||||
const items = await Promise.all(
|
||||
@@ -57,7 +57,7 @@ module.exports = async (ctx) => {
|
||||
return ctx.cache.tryGet(link, async () => {
|
||||
// 获取网页
|
||||
const { data: res } = await got(link);
|
||||
const content = cheerio.load(res);
|
||||
const content = load(res);
|
||||
|
||||
switch (url.host) {
|
||||
case 'mp.weixin.qq.com':
|
||||
@@ -92,9 +92,9 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `茂名市茂南区人民政府 - ${name}`,
|
||||
link: `${host}/${id}`,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const baseUrl = 'https://www.mee.gov.cn/';
|
||||
const columns = {
|
||||
@@ -14,11 +14,11 @@ const columns = {
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const cate = ctx.params.category ?? 'szyw';
|
||||
const cate = ctx.req.param('category') ?? 'szyw';
|
||||
const url = `${baseUrl}ywdt/`;
|
||||
const title = `${columns[cate].name} - 要闻动态 - 中华人民共和国生态环境部`;
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const all = $('.bd');
|
||||
const list = all
|
||||
.find(`div:nth-child(${columns[cate].order})`)
|
||||
@@ -47,7 +47,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
try {
|
||||
item.pubDate = timezone(parseDate(content('meta[name=PubDate]').attr('content')), +8);
|
||||
// 视频新闻规则不一样
|
||||
@@ -72,9 +72,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
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 { category = 'sggpdbqk' } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
|
||||
|
||||
const rootUrl = 'https://www.mem.gov.cn';
|
||||
const currentUrl = new URL(`gk/sgcc/${category}`, rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
let items = $('table.center_main02')
|
||||
.find('a[title]')
|
||||
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
|
||||
if (item.link.endsWith('html')) {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
|
||||
item.description = content('#content').html();
|
||||
}
|
||||
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
|
||||
|
||||
const icon = new URL($('link[rel="shortcut icon"]').prop('href'), rootUrl).href;
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
@@ -60,5 +60,5 @@ module.exports = async (ctx) => {
|
||||
logo: icon,
|
||||
subtitle: $('meta[name="ColumnName"]').prop('content'),
|
||||
author: $('meta[name="SiteName"]').prop('content'),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
+10
-10
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const categories = {
|
||||
gjldrhd: 'gjldrhd_674881',
|
||||
@@ -16,7 +16,7 @@ const categories = {
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'gjldrhd';
|
||||
const category = ctx.req.param('category') ?? 'gjldrhd';
|
||||
|
||||
const rootUrl = 'https://www.mfa.gov.cn';
|
||||
const currentUrl = `${rootUrl}/web/wjdt_674879/${categories[category]}`;
|
||||
@@ -26,10 +26,10 @@ module.exports = async (ctx) => {
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
let items = $('ul.list1 li a')
|
||||
.slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 35)
|
||||
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 35)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
@@ -48,7 +48,7 @@ module.exports = async (ctx) => {
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
item.description = content('#News_Body_Txt_A').html();
|
||||
item.pubDate = timezone(parseDate(content('.time span').last().text()), +8);
|
||||
@@ -59,9 +59,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
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';
|
||||
|
||||
const rootUrl = 'https://www.miit.gov.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const ministry = ctx.params.ministry;
|
||||
const ministry = ctx.req.param('ministry');
|
||||
const url = `${rootUrl}/jgsj/${ministry}/wjfb/index.html`;
|
||||
|
||||
const cookieResponse = await got(url);
|
||||
const cookie = cookieResponse.headers['set-cookie'][0].split(';')[0];
|
||||
const indexContent = cheerio.load(cookieResponse.data);
|
||||
const indexContent = load(cookieResponse.data);
|
||||
const title = indexContent('div.dqwz > a:nth-child(4)').text();
|
||||
const dataRequestUrl = indexContent('div.lmy_main_rb > script:nth-child(2)')
|
||||
.map((_, item) => ({
|
||||
@@ -29,7 +29,7 @@ module.exports = async (ctx) => {
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data.data.html);
|
||||
const $ = load(response.data.data.html);
|
||||
const list = $('ul > li')
|
||||
.map((_, item) => ({
|
||||
title: $(item).find('a').text(),
|
||||
@@ -42,7 +42,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
item.description = content('#con_con')
|
||||
.html()
|
||||
@@ -53,9 +53,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `工业和信息化部 - ${title} 文件发布`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
const baseUrl = 'https://www.miit.gov.cn';
|
||||
const siteUrl = `${baseUrl}/zwgk/wjgs/index.html`;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got(siteUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const buildStatic = $('script[parseType=buildstatic]');
|
||||
const requestUrl = buildStatic.attr('url');
|
||||
const queryData = JSON.parse(buildStatic.attr('querydata').replaceAll("'", '"'));
|
||||
@@ -18,7 +18,7 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
searchParams: queryData,
|
||||
});
|
||||
const list = cheerio.load(data.data.html, null, false);
|
||||
const list = load(data.data.html, null, false);
|
||||
|
||||
let items = list('.page-content ul li')
|
||||
.toArray()
|
||||
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data } = await got(item.link);
|
||||
const $ = cheerio.load(data);
|
||||
const $ = load(data);
|
||||
|
||||
$('iframe').each((_, e) => {
|
||||
e = $(e);
|
||||
@@ -54,9 +54,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `${$('head title').text()} - ${$('meta[name=SiteName]').attr('content')}`,
|
||||
link: siteUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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';
|
||||
|
||||
const rootUrl = 'https://www.miit.gov.cn';
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
|
||||
|
||||
const cookieResponse = await got(url);
|
||||
const cookie = cookieResponse.headers['set-cookie'][0].split(';')[0];
|
||||
const indexContent = cheerio.load(cookieResponse.data);
|
||||
const indexContent = load(cookieResponse.data);
|
||||
const dataRequestUrl = indexContent('div.clist_con > script:nth-child(2)')
|
||||
.map((_, item) => ({
|
||||
url: `${rootUrl}${indexContent(item).attr('url')}`,
|
||||
@@ -27,7 +27,7 @@ module.exports = async (ctx) => {
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data.data.html);
|
||||
const $ = load(response.data.data.html);
|
||||
const list = $('ul > li')
|
||||
.map((_, item) => ({
|
||||
title: $(item).find('a').text(),
|
||||
@@ -40,7 +40,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
item.description = content('#con_con')
|
||||
.html()
|
||||
@@ -51,9 +51,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `工业和信息化部 - 意见征集`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
const baseUrl = 'https://www.miit.gov.cn';
|
||||
const siteUrl = `${baseUrl}/zwgk/zcjd/index.html`;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got(siteUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const buildStatic = $('script[parseType=buildstatic]');
|
||||
const requestUrl = buildStatic.attr('url');
|
||||
const queryData = JSON.parse(buildStatic.attr('querydata').replaceAll("'", '"'));
|
||||
@@ -18,7 +18,7 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
searchParams: queryData,
|
||||
});
|
||||
const list = cheerio.load(data.data.html, null, false);
|
||||
const list = load(data.data.html, null, false);
|
||||
|
||||
let items = list('.page-content ul li')
|
||||
.toArray()
|
||||
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data } = await got(item.link);
|
||||
const $ = cheerio.load(data);
|
||||
const $ = load(data);
|
||||
|
||||
$('iframe').each((_, e) => {
|
||||
e = $(e);
|
||||
@@ -54,9 +54,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `${$('head title').text()} - ${$('meta[name=SiteName]').attr('content')}`,
|
||||
link: siteUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const base_url = 'http://www.miit.gov.cn/n1146295/n1652858/';
|
||||
const response = await got.get(base_url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const list = $('.clist_con li').get();
|
||||
|
||||
const ProcessFeed = (data) => {
|
||||
const $ = cheerio.load(data);
|
||||
const $ = load(data);
|
||||
|
||||
const content = $('p');
|
||||
return content.text();
|
||||
@@ -16,7 +16,7 @@ module.exports = async (ctx) => {
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const $ = load(item);
|
||||
const $a = $('a');
|
||||
let link = $a.attr('href');
|
||||
if (link.startsWith('..')) {
|
||||
@@ -44,10 +44,10 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '中国工业化和信息部',
|
||||
link: 'http://www.miit.gov.cn',
|
||||
description: '政策文件',
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseRelativeDate } from '@/utils/parse-date';
|
||||
|
||||
const hostUrl = 'http://www.moa.gov.cn/';
|
||||
const hostUrlObj = new URL(hostUrl); // 用于在下面判断host
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rawSuburl = ctx.params.suburl;
|
||||
const rawSuburl = ctx.req.param('suburl');
|
||||
const suburl = rawSuburl.slice(-1) === '/' ? rawSuburl : rawSuburl + '/';
|
||||
|
||||
// 特殊处理两个, 其他的栏目都可以找到那种一个列表下去的目录
|
||||
@@ -43,7 +43,7 @@ async function dealChannel(ctx, suburl, selectors) {
|
||||
// 为了与下面解析相对链接的dealLink配合, 这里末尾必须保证有一条斜杠
|
||||
const url = hostUrl + suburl;
|
||||
const respone = await got.get(url);
|
||||
const $ = cheerio.load(respone.data);
|
||||
const $ = load(respone.data);
|
||||
|
||||
const channelTitle = $(channelTitleSelector).text();
|
||||
|
||||
@@ -104,7 +104,7 @@ async function dealChannel(ctx, suburl, selectors) {
|
||||
// 处理正常文章, 例子: http://www.moa.gov.cn/gk/rsxx_1/202004/t20200421_6342037.htm
|
||||
async function dealNormalPage(link, item) {
|
||||
const reponse = await got.get(link);
|
||||
const $ = cheerio.load(reponse.data);
|
||||
const $ = load(reponse.data);
|
||||
const metaElements = $('.bjjMAuthorBox span.dc_3').toArray();
|
||||
|
||||
// 政府网站变动不频繁, 写死第几个应该没有多大关系
|
||||
@@ -127,7 +127,7 @@ async function dealNormalPage(link, item) {
|
||||
// 处理那种带索引号的公示文章, 例子: http://www.moa.gov.cn/govpublic/XZQYJ/202004/t20200420_6341913.htm
|
||||
async function dealGovpublicPage(link, item) {
|
||||
const respone = await got.get(link);
|
||||
const $ = cheerio.load(respone.data);
|
||||
const $ = load(respone.data);
|
||||
|
||||
const head = $('ul.head');
|
||||
const body = $('.arc_body');
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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 { category } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 5;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 5;
|
||||
|
||||
const domain = 'moa.gov.cn';
|
||||
const rootFrameUrl = `http://www.${domain}`;
|
||||
@@ -80,13 +80,13 @@ module.exports = async (ctx) => {
|
||||
|
||||
const { data: frameResponse } = await got(frameUrl);
|
||||
|
||||
const $ = cheerio.load(frameResponse);
|
||||
const $ = load(frameResponse);
|
||||
|
||||
const title = $('title').text();
|
||||
const description = '数据';
|
||||
const icon = new URL('favicon.ico', rootUrl).href;
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: `${title} - ${description} - ${category}`,
|
||||
link: currentUrl,
|
||||
@@ -98,5 +98,5 @@ module.exports = async (ctx) => {
|
||||
subtitle: category,
|
||||
author: title,
|
||||
allowEmpty: true,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const logger = require('@/utils/logger');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const moeUrl = 'https://www.moe.gov.cn/';
|
||||
const typesIdMap = [
|
||||
@@ -13,7 +13,7 @@ const typesIdMap = [
|
||||
];
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type;
|
||||
const type = ctx.req.param('type');
|
||||
let id = '';
|
||||
let name = '';
|
||||
|
||||
@@ -31,10 +31,10 @@ module.exports = async (ctx) => {
|
||||
|
||||
const response = await got(moeUrl);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const newsLis = $('div#' + id + '>ul>li');
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: name,
|
||||
link: moeUrl,
|
||||
item: await Promise.all(
|
||||
@@ -59,7 +59,7 @@ module.exports = async (ctx) => {
|
||||
Referer: moeUrl,
|
||||
},
|
||||
});
|
||||
const data = cheerio.load(response.data);
|
||||
const data = load(response.data);
|
||||
|
||||
if (itemUrl.includes('www.gov.cn')) {
|
||||
res.description = data('#UCAP-CONTENT').html();
|
||||
@@ -81,5 +81,5 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
.get()
|
||||
),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://www.moe.gov.cn';
|
||||
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
|
||||
const link = `${baseUrl}/s78/${column}/tongzhi/`;
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const list = $('#list li')
|
||||
.toArray()
|
||||
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
$('#moe-detail-page-set, #moeCode, .moe-detail-shuxing, h1').remove();
|
||||
item.description = $('.moe-detail-box').html();
|
||||
@@ -36,9 +36,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `${$('meta[name="ColumnType"]').attr('content')} - ${$('head title').text()}`,
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const domain = 'gks.mof.gov.cn';
|
||||
const theme = 'guozaiguanli';
|
||||
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
|
||||
const { category = 'gzfxgzdt' } = ctx.params;
|
||||
const currentUrl = `https://${domain}/ztztz/${theme}/${category}/`;
|
||||
const { data: response } = await got(currentUrl);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const title = $('title').text();
|
||||
const author = $('div.zzName').text();
|
||||
const siteName = $('meta[name="SiteName"]').prop('content');
|
||||
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
|
||||
indexes.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
item.description = content('div.my_doccontent').html();
|
||||
item.author = author;
|
||||
return item;
|
||||
@@ -41,11 +41,11 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title,
|
||||
link: currentUrl,
|
||||
description: `${description} - ${siteName}`,
|
||||
author,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import { load } from 'cheerio';
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const host = 'http://www.mofcom.gov.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const suffix = ctx.params.suffix;
|
||||
const suffix = ctx.req.param('suffix');
|
||||
const url = `http://www.mofcom.gov.cn/article/${suffix}/`;
|
||||
const { data: res } = await got(url);
|
||||
const $ = cheerio.load(res);
|
||||
const $ = load(res);
|
||||
$('.listline').remove();
|
||||
const list = $('.txtList_01 li')
|
||||
.toArray()
|
||||
@@ -45,11 +45,11 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
});
|
||||
}
|
||||
const $ = cheerio.load(responses.data);
|
||||
const $ = load(responses.data);
|
||||
const iframe = $('.art-con iframe').attr('src');
|
||||
if ($('.art-con iframe').attr('src')) {
|
||||
const { data: res } = await got(iframe);
|
||||
item.description = cheerio.load(res)('tbody').html();
|
||||
item.description = load(res)('tbody').html();
|
||||
} else {
|
||||
item.description = $('.art-con').html() || /* xwfb/xwztfbh */ $('.textlive').html();
|
||||
}
|
||||
@@ -59,10 +59,10 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
)
|
||||
);
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('head > title').text(),
|
||||
description: $('meta[name=description]').attr('content'),
|
||||
link: url,
|
||||
item: list,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
const baseUrl = 'https://www.aac.moj.gov.tw';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { type } = ctx.params;
|
||||
const url = `${baseUrl}/7204/7246/?Page=1&PageSize=40${type ? `&type=${type}` : ''}`;
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
$('.num').remove();
|
||||
const list = $('.list ul li a')
|
||||
.toArray()
|
||||
@@ -28,7 +28,7 @@ module.exports = async (ctx) => {
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
if (!item.isDownload) {
|
||||
const response = await got(item.link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
item.pubDate = timezone(parseDate($('.info time').attr('datetime'), 'YYYY-MM-DD HH:mm:ss'), +8);
|
||||
$('.info, button').remove();
|
||||
@@ -40,10 +40,10 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('head title').text(),
|
||||
link: url,
|
||||
item: items,
|
||||
language: 'zh-TW',
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const DOMAIN = 'www.moj.gov.cn';
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
|
||||
const rootUrl = `https://${DOMAIN}`;
|
||||
const currentUrl = `${rootUrl}/lfyjzj/lflfyjzj/index.html`;
|
||||
const { data: response } = await got(currentUrl);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const siteName = $('title:first').text();
|
||||
const theme = $('div.list_title').text();
|
||||
const description = `${siteName} - ${theme}`;
|
||||
@@ -32,7 +32,7 @@ module.exports = async (ctx) => {
|
||||
indexes.map((item) =>
|
||||
ctx.cache.tryGet(`gov:mof:${item.link}`, async () => {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
item.description = content('div.TRS_Editor').html();
|
||||
item.author = content('div.sT_left span:first').text().split(':')[1];
|
||||
const pubDate = content('div.sT_left span:last').text().split(':')[1];
|
||||
@@ -42,12 +42,12 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: theme,
|
||||
link: currentUrl,
|
||||
description,
|
||||
author: siteName,
|
||||
icon,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { category = 'tongjishuju/gonglu' } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
|
||||
|
||||
const rootUrl = 'https://www.mot.gov.cn';
|
||||
const currentUrl = new URL(`${category}/`, rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
let items = $('div.tab-pane a[title]')
|
||||
.slice(0, limit)
|
||||
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
|
||||
if (/\.gov\.cn/.test(item.link) && item.link.endsWith('.html')) {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
|
||||
item.title = content('meta[name="ArticleTitle"]').prop('content') || content('h1#ti').text();
|
||||
item.description = content('div.TRS_UEDITOR').html();
|
||||
@@ -53,7 +53,7 @@ module.exports = async (ctx) => {
|
||||
|
||||
const image = new URL($('a.navbar-brand img').prop('src'), rootUrl).href;
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
@@ -62,5 +62,5 @@ module.exports = async (ctx) => {
|
||||
image,
|
||||
subtitle: $('meta[name="ColumnName"]').prop('content'),
|
||||
author: $('meta[name="SiteName"]').prop('content'),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { category } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 25;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 25;
|
||||
|
||||
const rootUrl = 'https://www.ndrc.gov.cn';
|
||||
const currentUrl = new URL(`fggz${category ? `/${category.endsWith('/') ? category : `${category}/`}` : '/'}`, rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
let items = $('ul.u-list li a')
|
||||
.slice(0, limit)
|
||||
@@ -32,7 +32,7 @@ module.exports = async (ctx) => {
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
|
||||
item.title = content('meta[name="ArticleTitle"]').prop('content');
|
||||
item.description = content('div.TRS_Editor').html();
|
||||
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
|
||||
|
||||
const image = $('div.logo a img').prop('src');
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
@@ -58,5 +58,5 @@ module.exports = async (ctx) => {
|
||||
image,
|
||||
subtitle: $('meta[name="ColumnName"]').prop('content'),
|
||||
author: $('meta[name="SiteName"]').prop('content'),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category || 'xwfb';
|
||||
const category = ctx.req.param('category') || 'xwfb';
|
||||
|
||||
const rootUrl = 'https://www.ndrc.gov.cn';
|
||||
const currentUrl = category.includes('dt') ? `${rootUrl}/xwdt/dt/${category}` : `${rootUrl}/xwdt/${category}`;
|
||||
@@ -11,7 +11,7 @@ module.exports = async (ctx) => {
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const list = $('.u-list li a')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
@@ -36,7 +36,7 @@ module.exports = async (ctx) => {
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
item.description = content('.TRS_Editor').html() || content('.article_con').html();
|
||||
item.pubDate = new Date(content('meta[name="PubDate"]').attr('content') + ' GMT+8').toUTCString();
|
||||
@@ -46,9 +46,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 35;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 35;
|
||||
|
||||
const rootUrl = 'https://www.nea.gov.cn';
|
||||
const currentUrl = new URL('sjzz/ghs/', rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
let items = $('div.right_box ul li')
|
||||
.slice(0, limit)
|
||||
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
|
||||
item.title = content('meta[name="ArticleTitle"]').prop('content');
|
||||
item.description = content('td.detail').html() || content('div.article-content td').html();
|
||||
@@ -46,7 +46,7 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
@@ -54,5 +54,5 @@ module.exports = async (ctx) => {
|
||||
language: 'zh',
|
||||
subtitle: $('meta[name="ColumnType"]').prop('content'),
|
||||
author: $('meta[name="ColumnKeywords"]').prop('content'),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
+10
-10
@@ -1,11 +1,11 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const logger = require('@/utils/logger');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const uid = ctx.params.uid;
|
||||
const uid = ctx.req.param('uid');
|
||||
const originDomain = 'https://www.gov.cn';
|
||||
let url = '';
|
||||
let title = '';
|
||||
@@ -36,7 +36,7 @@ module.exports = async (ctx) => {
|
||||
logger.error('pattern not matched');
|
||||
}
|
||||
const listData = await got.get(url);
|
||||
const $ = cheerio.load(listData.data);
|
||||
const $ = load(listData.data);
|
||||
if (url.includes('zhengcelibrary')) {
|
||||
list = $('.dys_middle_result_content_item');
|
||||
} else if (url.includes('bumen')) {
|
||||
@@ -45,7 +45,7 @@ module.exports = async (ctx) => {
|
||||
list = $('.news_box .list li:not(.line)');
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title,
|
||||
link: url,
|
||||
item: await Promise.all(
|
||||
@@ -63,7 +63,7 @@ module.exports = async (ctx) => {
|
||||
if (/dysMiddleResultConItemTitle/g.test(item.html())) {
|
||||
if (contentUrl.includes('content')) {
|
||||
fullTextGet = await got.get(contentUrl);
|
||||
fullTextData = cheerio.load(fullTextGet.data);
|
||||
fullTextData = load(fullTextGet.data);
|
||||
fullTextData('.shuzi').remove(); // 移除videobg的图片
|
||||
fullTextData('#myFlash').remove(); // 移除flash
|
||||
description = /pages_content/g.test(fullTextData.html()) ? fullTextData('.pages_content').html() : fullTextData('#UCAP-CONTENT').html();
|
||||
@@ -73,7 +73,7 @@ module.exports = async (ctx) => {
|
||||
} else {
|
||||
if (contentUrl.includes('content')) {
|
||||
fullTextGet = await got.get(contentUrl);
|
||||
fullTextData = cheerio.load(fullTextGet.data);
|
||||
fullTextData = load(fullTextGet.data);
|
||||
const $1 = fullTextData.html();
|
||||
pubDate = timezone(parseDate(fullTextData('meta[name="firstpublishedtime"]').attr('content'), 'YYYY-MM-DD HH:mm:ss'), 8);
|
||||
author = fullTextData('meta[name="author"]').attr('content');
|
||||
@@ -101,5 +101,5 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
})
|
||||
),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { path = 'bshff/ylqxbzhgl/qxggtzh' } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
|
||||
|
||||
const rootUrl = 'https://www.nifdc.org.cn';
|
||||
const currentUrl = new URL(`nifdc/${path}/`, rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
let items = $('div.list ul li')
|
||||
.slice(0, limit)
|
||||
@@ -36,7 +36,7 @@ module.exports = async (ctx) => {
|
||||
try {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
|
||||
item.title = content('.title').text();
|
||||
item.description = content('div.text').append(content('div.fujian')).html();
|
||||
@@ -63,7 +63,7 @@ module.exports = async (ctx) => {
|
||||
const image = new URL($('div.logo img').prop('src'), currentUrl).href;
|
||||
const icon = new URL($('link[rel="shortcut icon"]').prop('href'), currentUrl).href;
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: $('title').text().replace(/----/, ' - '),
|
||||
link: currentUrl,
|
||||
@@ -74,5 +74,5 @@ module.exports = async (ctx) => {
|
||||
logo: icon,
|
||||
subtitle: $('meta[ name="ColumnName"]').prop('content'),
|
||||
author: $('meta[name="SiteName"]').prop('content'),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
const { finishArticleItem } = require('@/utils/wechat-mp');
|
||||
const config = require('@/config').value;
|
||||
import { config } from '@/config';
|
||||
const baseUrl = 'https://www.nmpa.gov.cn';
|
||||
const got = require('@/utils/got');
|
||||
import got from '@/utils/got';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const path = ctx.params[0];
|
||||
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
|
||||
url,
|
||||
async () => {
|
||||
const { data: html } = await got(url);
|
||||
const $ = cheerio.load(html);
|
||||
const $ = load(html);
|
||||
|
||||
return {
|
||||
title: $('head title').text(),
|
||||
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
|
||||
if (/^https:\/\/www\.nmpa\.gov\.cn\//.test(item.link)) {
|
||||
return ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: html } = await got(item.link);
|
||||
const $ = cheerio.load(html);
|
||||
const $ = load(html);
|
||||
item.description = $('.text').html();
|
||||
item.pubDate = timezone(parseDate($('meta[name="PubDate"]').attr('content')), +8);
|
||||
return item;
|
||||
@@ -52,10 +52,10 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const params = ctx.path === '/nopss' ? '/GB/219469' : ctx.path.replace(/^\/nopss/, '');
|
||||
@@ -16,10 +16,10 @@ module.exports = async (ctx) => {
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
|
||||
const $ = load(iconv.decode(response.data, 'gbk'));
|
||||
|
||||
let items = $('.p2j_list_con .clearfix li a')
|
||||
.slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 40)
|
||||
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 40)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
@@ -40,7 +40,7 @@ module.exports = async (ctx) => {
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
|
||||
const content = load(iconv.decode(detailResponse.data, 'gbk'));
|
||||
|
||||
item.description = content('.text_con').html();
|
||||
|
||||
@@ -49,9 +49,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { caty } = ctx.params;
|
||||
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
|
||||
const baseurl = `http://www.npc.gov.cn/npc/c2/${caty}/`;
|
||||
const response = await got(baseurl);
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
const $ = load(data);
|
||||
const title = $('title').text();
|
||||
// 获取每条的链接
|
||||
const links = $('.clist a')
|
||||
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
|
||||
ctx.cache.tryGet(link, async () => {
|
||||
const response = await got(link);
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
const $ = load(data);
|
||||
const title = $('title').text().replace('_中国人大网', '');
|
||||
const time = $('script:contains("fbrq")')
|
||||
.text()
|
||||
@@ -38,10 +38,10 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
// 整合
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title,
|
||||
link: baseurl,
|
||||
description: title,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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';
|
||||
const asyncPool = require('tiny-async-pool');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { category = 'note' } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 15;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 15;
|
||||
|
||||
const rootUrl = 'https://dsj.nrta.gov.cn';
|
||||
const currentUrl = new URL(`tims/site/views/applications.shanty?appName=${category}`, rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const items = $('img[src="/site/styles/default/images/icon_arrow_r.gif"]')
|
||||
.slice(0, limit)
|
||||
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
|
||||
content('table').last().remove();
|
||||
|
||||
@@ -47,7 +47,7 @@ module.exports = async (ctx) => {
|
||||
results.push(item);
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: results,
|
||||
title: `${$('title').text()}-${$('div.headbottom_menu_selected').text()}`,
|
||||
link: currentUrl,
|
||||
@@ -55,5 +55,5 @@ module.exports = async (ctx) => {
|
||||
language: 'zh-cn',
|
||||
image: $('img').first().prop('src'),
|
||||
author: '国家广播电影电视总局电视剧管理司',
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const categories = {
|
||||
112: '总局要闻',
|
||||
@@ -10,7 +10,7 @@ const categories = {
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 112;
|
||||
const category = ctx.req.param('category') ?? 112;
|
||||
|
||||
const rootUrl = 'http://www.nrta.gov.cn';
|
||||
|
||||
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
|
||||
const regex = /<!\[cdata\[([\S\s]*?)]]>(?=\s*<)/gi;
|
||||
const data = response.data.replaceAll(regex, '$1');
|
||||
|
||||
const $ = cheerio.load(data, {
|
||||
const $ = load(data, {
|
||||
xmlMode: true,
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ module.exports = async (ctx) => {
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
item.title = content('td[id="artTitMob"]').text();
|
||||
item.description = content('div[id="c"]').html();
|
||||
item.pubDate = timezone(parseDate(content('.mobile_time.shareWarpTime').text().trim()), +8);
|
||||
@@ -52,11 +52,11 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
)
|
||||
);
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: category in categories ? categories[category] : '其他',
|
||||
link: `http://www.nrta.gov.cn/col/col${category}/index.html`,
|
||||
description: '国家广播电视总局',
|
||||
language: 'zh-cn',
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
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';
|
||||
|
||||
const shortcuts = require('./shortcuts');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let thePath = ctx.path.replace(/^\/nsfc/, '');
|
||||
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
|
||||
|
||||
const shortcutMatches = thePath.match(/(\/news)?\/([\w-]+)/);
|
||||
|
||||
@@ -27,7 +27,7 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
let items = $('span.fl a, ul.dp_lia li a')
|
||||
.slice(0, limit)
|
||||
@@ -52,7 +52,7 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
|
||||
item.title = content('div.title_xilan').text();
|
||||
item.description = content('#zoom').html();
|
||||
@@ -69,7 +69,7 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: `国家自然科学基金委员会 - ${$('#ess_essBREADCRUMB_lblBreadCrumb a.break')
|
||||
.toArray()
|
||||
@@ -81,5 +81,5 @@ module.exports = async (ctx) => {
|
||||
language: 'zh-cn',
|
||||
subtitle: $('meta[name="KEYWORDS"]').prop('content'),
|
||||
author: $('meta[name="AUTHOR"]').prop('content'),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
import puppeteer from '@/utils/puppeteer';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = 'http://www.pbc.gov.cn/goutongjiaoliu/113456/113469/index.html';
|
||||
|
||||
const browser = await require('@/utils/puppeteer')({ stealth: true });
|
||||
const browser = puppeteer({ stealth: true });
|
||||
const page = await browser.newPage();
|
||||
await page.setRequestInterception(true);
|
||||
page.on('request', (request) => {
|
||||
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
const html = await page.evaluate(() => document.documentElement.innerHTML);
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
const $ = load(html);
|
||||
const list = $('font.newslist_style')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
|
||||
waitUntil: 'domcontentloaded',
|
||||
});
|
||||
const detailHtml = await detailPage.evaluate(() => document.documentElement.innerHTML);
|
||||
const content = cheerio.load(detailHtml);
|
||||
const content = load(detailHtml);
|
||||
item.description = content('#zoom').html();
|
||||
item.pubDate = timezone(parseDate(content('.hui12').eq(5).text()), +8);
|
||||
return item;
|
||||
@@ -50,9 +51,9 @@ module.exports = async (ctx) => {
|
||||
|
||||
browser.close();
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '中国人民银行 - 沟通交流',
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { processItems } = require('./utils');
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
const host = 'http://www.pbc.gov.cn';
|
||||
|
||||
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
|
||||
const url = `${host}/redianzhuanti/118742/4122386/4122692/index.html`;
|
||||
|
||||
const response = await got.post(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const list = $('li.clearfix')
|
||||
.map((_index, item) => ({
|
||||
title: $(item).find('a').text(),
|
||||
@@ -19,9 +19,9 @@ module.exports = async (ctx) => {
|
||||
|
||||
const items = await processItems(list, ctx);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '中国人民银行 工作论文',
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
import puppeteer from '@/utils/puppeteer';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = 'http://www.pbc.gov.cn/zhengcehuobisi/125207/125213/125431/125475/index.html';
|
||||
|
||||
const browser = await require('@/utils/puppeteer')();
|
||||
const browser = puppeteer();
|
||||
const page = await browser.newPage();
|
||||
await page.setRequestInterception(true);
|
||||
page.on('request', (request) => {
|
||||
@@ -15,7 +16,7 @@ module.exports = async (ctx) => {
|
||||
waitUntil: 'domcontentloaded',
|
||||
});
|
||||
const html = await page.evaluate(() => document.documentElement.innerHTML);
|
||||
const $ = cheerio.load(html);
|
||||
const $ = load(html);
|
||||
const list = $('font.newslist_style')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
|
||||
waitUntil: 'domcontentloaded',
|
||||
});
|
||||
const detailHtml = await detailPage.evaluate(() => document.documentElement.innerHTML);
|
||||
const content = cheerio.load(detailHtml);
|
||||
const content = load(detailHtml);
|
||||
item.description = content('#zoom').html();
|
||||
item.pubDate = timezone(parseDate(content('#shijian').text()), +8);
|
||||
return item;
|
||||
@@ -49,9 +50,9 @@ module.exports = async (ctx) => {
|
||||
|
||||
browser.close();
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '中国人民银行 - 货币政策司公开市场交易公告',
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
const processItems = (list, ctx) =>
|
||||
Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got.post(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
item.description = content('div.xxy_text').html();
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const { processItems } = require('./utils');
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const host = 'http://www.pbc.gov.cn';
|
||||
|
||||
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
|
||||
const url = `${host}/redianzhuanti/118742/4122386/4122510/index.html`;
|
||||
|
||||
const response = await got.post(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const list = $('li.clearfix')
|
||||
.map((_index, item) => ({
|
||||
title: $(item).find('a').text(),
|
||||
@@ -21,9 +21,9 @@ module.exports = async (ctx) => {
|
||||
|
||||
const items = await processItems(list, ctx);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '中国人民银行 政策研究',
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ const { processZxfkItems } = require('./util');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { site = 'beijing' } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 3;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 3;
|
||||
|
||||
ctx.state.data = await processZxfkItems(site, 'ywzx', limit);
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ const { processZxfkItems } = require('./util');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { site = 'beijing' } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 5;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 5;
|
||||
|
||||
ctx.state.data = await processZxfkItems(site, 'tsjy', limit);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
|
||||
const rootUrl = 'https://www.safe.gov.cn';
|
||||
@@ -20,7 +20,7 @@ const processZxfkItems = async (site = 'beijing', category = 'ywzx', limit = '3'
|
||||
|
||||
const { data: response } = await got(apiUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const items = $('#complaint')
|
||||
.slice(0, limit)
|
||||
@@ -58,7 +58,7 @@ const processZxfkItems = async (site = 'beijing', category = 'ywzx', limit = '3'
|
||||
|
||||
const { data: currentResponse } = await got(currentUrl);
|
||||
|
||||
const content = cheerio.load(currentResponse);
|
||||
const content = load(currentResponse);
|
||||
|
||||
const author = content('meta[name="ColumnName"]').prop('content');
|
||||
const subtitle = content('meta[name="ColumnType"]').prop('content');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
|
||||
const rootUrl = 'https://xgzlyhd.samr.gov.cn';
|
||||
@@ -36,7 +36,7 @@ const getOption = async (type, name) => {
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { category, department } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 10;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 10;
|
||||
|
||||
let categoryOption;
|
||||
let departmentOption;
|
||||
@@ -77,14 +77,14 @@ module.exports = async (ctx) => {
|
||||
|
||||
const { data: currentResponse } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(currentResponse);
|
||||
const $ = load(currentResponse);
|
||||
|
||||
const author = '国家市场监督管理总局';
|
||||
const title = $('title').text();
|
||||
const subtitle = [categoryOption ? categoryOption.name : undefined, departmentOption ? departmentOption.name : undefined].filter(Boolean).join(' - ');
|
||||
const icon = new URL($('link[rel="icon"]').prop('href'), rootUrl).href;
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: `${author}${title}${subtitle ? ` - ${subtitle}` : ''}`,
|
||||
link: currentUrl,
|
||||
@@ -96,5 +96,5 @@ module.exports = async (ctx) => {
|
||||
subtitle,
|
||||
author,
|
||||
allowEmpty: true,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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 { path } = ctx.params;
|
||||
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
|
||||
const url = `${baseUrl}/${path}/index.html`;
|
||||
const response = await got(url);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const list = $('.zsy_conlist li')
|
||||
.toArray()
|
||||
.filter((item) => !$(item).attr('style'))
|
||||
@@ -25,7 +25,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got(item.link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
$('style, #qr_container, #div_div, [class^=jiathis]').remove();
|
||||
item.description = $('.zsy_comain').html();
|
||||
return item;
|
||||
@@ -33,10 +33,10 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('head title').text().trim(),
|
||||
link: url,
|
||||
image: 'http://www.sasac.gov.cn/dbsource/11869722/11869731.jpg',
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id ?? '221';
|
||||
const id = ctx.req.param('id') ?? '221';
|
||||
|
||||
const rootUrl = 'https://kjt.shaanxi.gov.cn';
|
||||
const currentUrl = `${rootUrl}/view/iList.jsp?cat_id=${id}`;
|
||||
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
let items = $('.textlist li a')
|
||||
.toArray()
|
||||
@@ -36,7 +36,7 @@ module.exports = async (ctx) => {
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
item.description = content('.info_content').html();
|
||||
item.author = content('meta[name="Author"]').attr('content');
|
||||
@@ -47,9 +47,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `陕西省科学技术厅 - ${$('.catnm').text()}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
const { art } = require('@/utils/render');
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
|
||||
const rootUrl = 'http://www.rsj.sh.gov.cn';
|
||||
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
|
||||
responseType: 'buffer',
|
||||
});
|
||||
const dataHtml = iconv.decode(response.data, 'gbk');
|
||||
const $ = cheerio.load(dataHtml);
|
||||
const $ = load(dataHtml);
|
||||
|
||||
const items = $('kwap')
|
||||
.map((_, item) => ({
|
||||
@@ -31,9 +31,9 @@ module.exports = async (ctx) => {
|
||||
}))
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '上海市职业能力考试院 - 考试项目',
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'http://wsbs.wgj.sh.gov.cn';
|
||||
const currentUrl = `${baseUrl}/shwgj_ywtb/core/web/welcome/index!toResultNotice.action`;
|
||||
const page = ctx.params.page ?? 1;
|
||||
const page = ctx.req.param('page') ?? 1;
|
||||
const searchParams = {
|
||||
flag: 1,
|
||||
'pageDoc.pageNo': page,
|
||||
@@ -18,7 +18,7 @@ module.exports = async (ctx) => {
|
||||
searchParams,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const list = $('#div_md > table > tbody > tr > td:nth-child(1) > a')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
|
||||
method: 'get',
|
||||
url: baseUrl + item.link,
|
||||
});
|
||||
const $ = cheerio.load(detailResponse.data);
|
||||
const $ = load(detailResponse.data);
|
||||
const dateElement = $('div[align="right"][style*="padding: 10px"]').last();
|
||||
const dateText = dateElement.text().trim();
|
||||
const hostingUnit = $('td:contains("举办单位:")').next().text().trim();
|
||||
@@ -64,9 +64,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import { load } from 'cheerio';
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = `https://wsjkw.sh.gov.cn/yqtb/index.html`;
|
||||
|
||||
const res = await got.get(url);
|
||||
const $ = cheerio.load(res.data);
|
||||
const $ = load(res.data);
|
||||
const list = $('.uli16.nowrapli.list-date li');
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '疫情通报-上海卫健委',
|
||||
link: url,
|
||||
item:
|
||||
@@ -29,5 +29,5 @@ module.exports = async (ctx) => {
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const params = ctx.path === '/shanghai/yjj' ? '/shanghai/yjj/zx-ylqx' : ctx.path;
|
||||
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
let items = $('.pageList li a')
|
||||
.toArray()
|
||||
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
const pubDate = content('meta[name="pubdate"]').attr('content') || content('meta[name="PubDate"]').attr('content');
|
||||
|
||||
@@ -54,9 +54,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('title').text().replace(/--/, ' - '),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const rootURL = 'http://hrss.sz.gov.cn/';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const categoryID = ctx.params.caty;
|
||||
const page = ctx.params.page ?? '1';
|
||||
const categoryID = ctx.req.param('caty');
|
||||
const page = ctx.req.param('page') ?? '1';
|
||||
|
||||
const pageParam = Number.parseInt(page) > 1 ? `_${page}` : '';
|
||||
const pagePath = `/szksy/zwgk/${categoryID}/index${pageParam}.html`;
|
||||
@@ -18,7 +18,7 @@ module.exports = async (ctx) => {
|
||||
throw new Error(response.statusMessage);
|
||||
}
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const title = $('.zx_rm_tit span').text().trim();
|
||||
const list = $('.zx_ml_list ul li')
|
||||
.slice(1)
|
||||
@@ -33,9 +33,9 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '深圳市考试院 - ' + title,
|
||||
link: currentURL.href,
|
||||
item: list,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
const rootUrl = 'http://www.sz.gov.cn/cn/xxgk/zfxxgj/';
|
||||
|
||||
const config = {
|
||||
@@ -24,14 +24,14 @@ const config = {
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const cfg = config[ctx.params.caty];
|
||||
const cfg = config[ctx.req.param('caty')];
|
||||
if (!cfg) {
|
||||
throw new Error('Bad category. See <a href="https://docs.rsshub.app/routes/government#guang-dong-sheng-ren-min-zheng-fu-guang-dong-sheng-shen-zhen-shi-ren-min-zheng-fu">docs</a>');
|
||||
}
|
||||
|
||||
const currentUrl = new URL(cfg.link, rootUrl).href;
|
||||
const response = await got(currentUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const list = $('div.zx_ml_list ul li span.tit')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
@@ -46,7 +46,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
item.description = content('div.news_cont_d_wrap').html();
|
||||
if (content('div.fjdown').html() !== null) {
|
||||
item.description += content('div.fjdown').html();
|
||||
@@ -64,9 +64,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '广东省深圳市人民政府 - ' + cfg.title,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const config = {
|
||||
tzgg: {
|
||||
@@ -12,7 +12,7 @@ const config = {
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'http://zjj.sz.gov.cn/xxgk/';
|
||||
const cfg = config[ctx.params.caty];
|
||||
const cfg = config[ctx.req.param('caty')];
|
||||
if (!cfg) {
|
||||
throw new Error('Bad category. See <a href="https://docs.rsshub.app/routes/government#guang-dong-sheng-ren-min-zheng-fu-shen-zhen-shi-zhu-fang-he-jian-she-ju">docs</a>');
|
||||
}
|
||||
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
|
||||
const currentUrl = new URL(cfg.link, baseUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const items = $('div.listcontent_right ul li')
|
||||
// 使用“toArray()”方法将选择的所有 DOM 元素以数组的形式返回。
|
||||
@@ -37,9 +37,9 @@ module.exports = async (ctx) => {
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '深圳市住房和建设局 - ' + cfg.title,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const rootURL = 'http://www.zzb.sz.gov.cn/';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const categoryID = ctx.params.caty;
|
||||
const page = ctx.params.page ?? '1';
|
||||
const categoryID = ctx.req.param('caty');
|
||||
const page = ctx.req.param('page') ?? '1';
|
||||
|
||||
const pageParam = Number.parseInt(page) > 1 ? `_${page}` : '';
|
||||
const pagePath = `/${categoryID}/index${pageParam}.html`;
|
||||
@@ -18,7 +18,7 @@ module.exports = async (ctx) => {
|
||||
throw new Error(response.statusMessage);
|
||||
}
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const title = $('#Title').text().trim();
|
||||
const list = $('#List tbody tr td table tbody tr td[width="96%"]')
|
||||
.map((_, item) => {
|
||||
@@ -32,9 +32,9 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '深圳组工在线 - ' + title,
|
||||
link: currentURL.href,
|
||||
item: list,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
// 各地区url信息
|
||||
const basicInfoDict = {
|
||||
@@ -24,7 +24,7 @@ const basicInfoDict = {
|
||||
|
||||
const getInfoUrlList = async (rootUrl, infoBasicUrl) => {
|
||||
const response = await got(infoBasicUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
// 非当前日期文章计数,部分旧文章可能会置顶,目前为发现置顶数超过10
|
||||
const infoList = $('body > div.container > div.ewb-white > div.ewb-job > ul > li')
|
||||
.toArray()
|
||||
@@ -41,7 +41,7 @@ const getInfoContent = (ctx, rootUrl, item) =>
|
||||
const response = await got(item.url);
|
||||
// 部分网页会跳转其他类型网站,则不解析,直接附超链接
|
||||
try {
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const fileList = $('#symbol > div:nth-child(4) > div > span > a')
|
||||
.toArray()
|
||||
.map((item) => ({
|
||||
@@ -72,14 +72,14 @@ const getInfoContent = (ctx, rootUrl, item) =>
|
||||
});
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const countyName = ctx.params.countyName;
|
||||
const infoType = ctx.params.infoType || 'fdzdnr';
|
||||
const countyName = ctx.req.param('countyName');
|
||||
const infoType = ctx.req.param('infoType') || 'fdzdnr';
|
||||
const infoBasicUrl = basicInfoDict[countyName].infoType[infoType].basicUrl;
|
||||
const rootUrl = basicInfoDict[countyName].rootUrl;
|
||||
const infoUrlList = await getInfoUrlList(rootUrl, infoBasicUrl);
|
||||
const items = await Promise.all(infoUrlList.map((item) => getInfoContent(ctx, rootUrl, item)));
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `政府公开信息-${countyName}-${basicInfoDict[countyName].infoType[infoType].name}`,
|
||||
link: infoBasicUrl,
|
||||
item: items.map((item) => ({
|
||||
@@ -88,5 +88,5 @@ module.exports = async (ctx) => {
|
||||
link: item.link,
|
||||
pubDate: item.pubDate,
|
||||
})),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const rootUrl = 'http://www.mztoday.gov.cn';
|
||||
const basicInfoDict = {
|
||||
@@ -91,7 +91,7 @@ const basicInfoDict = {
|
||||
|
||||
const getInfoUrlList = async (url) => {
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const infoList = $('div.sl')
|
||||
.toArray()
|
||||
.map((item) => ({
|
||||
@@ -106,7 +106,7 @@ const getInfoUrlList = async (url) => {
|
||||
const getInfoContent = (ctx, item) =>
|
||||
ctx.cache.tryGet(item.url, async () => {
|
||||
const response = await got(item.url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
return {
|
||||
title: item.title,
|
||||
content: $('td:nth-child(2)').html(),
|
||||
@@ -116,12 +116,12 @@ const getInfoContent = (ctx, item) =>
|
||||
});
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const infoType = ctx.params.infoType || 'zx';
|
||||
const infoType = ctx.req.param('infoType') || 'zx';
|
||||
const infoBasicUrl = `${rootUrl}${basicInfoDict[infoType].url}`;
|
||||
const infoUrlList = await getInfoUrlList(infoBasicUrl);
|
||||
const items = await Promise.all(infoUrlList.map((item) => getInfoContent(ctx, item)));
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `今日绵竹-${basicInfoDict[infoType].name}`,
|
||||
link: `${infoBasicUrl}1`,
|
||||
item: items.map((item) => ({
|
||||
@@ -130,5 +130,5 @@ module.exports = async (ctx) => {
|
||||
link: item.link,
|
||||
pubDate: item.pubDate,
|
||||
})),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
+10
-10
@@ -1,12 +1,12 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 15;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 15;
|
||||
|
||||
const defaultPath = '/sj/zxfb/';
|
||||
|
||||
@@ -28,7 +28,7 @@ module.exports = async (ctx) => {
|
||||
headers,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
let items = $($('a.pchide').length === 0 ? 'a[title]' : '.list-content a.pchide')
|
||||
.slice(0, limit)
|
||||
@@ -51,7 +51,7 @@ module.exports = async (ctx) => {
|
||||
headers,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
// articles from www.news.cn or www.gov.cn
|
||||
|
||||
@@ -104,9 +104,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = 'https://www.suzhou.gov.cn/szxxgk/front/xxgk_right.jsp';
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const list = $('.tr_main_value_odd')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
item.description = $('.article-content').html();
|
||||
item.author = $('dd.addWidth:nth-child(3) div').text().trim();
|
||||
@@ -38,9 +38,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '苏州市政府 - 政策公开文件',
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { category = 'szfgw/ggl/nav_list' } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 30;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
|
||||
|
||||
const rootUrl = 'https://fg.suzhou.gov.cn';
|
||||
const currentUrl = new URL(`${category}.shtml`, rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
let items = $('h4 a[title]')
|
||||
.slice(0, limit)
|
||||
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
|
||||
item.title = content('ucaptitle').text().trim();
|
||||
item.description = content('ucapcontent').html();
|
||||
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
|
||||
const subtitle = $('meta[name="ColumnName"]').prop('content');
|
||||
const image = new URL($('div.logo img').prop('src'), rootUrl).href;
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: `${author} - ${subtitle}`,
|
||||
link: currentUrl,
|
||||
@@ -58,5 +58,5 @@ module.exports = async (ctx) => {
|
||||
image,
|
||||
subtitle,
|
||||
author,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.suzhou.gov.cn';
|
||||
const uid = ctx.params.uid;
|
||||
const uid = ctx.req.param('uid');
|
||||
let url = '';
|
||||
let title = '';
|
||||
let apiUrl = '';
|
||||
@@ -84,7 +84,7 @@ module.exports = async (ctx) => {
|
||||
// 获取全文
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got(item.link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
item.description = $('ucapcontent').html();
|
||||
|
||||
return item;
|
||||
@@ -94,7 +94,7 @@ module.exports = async (ctx) => {
|
||||
} else {
|
||||
const response = await got(url);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
items = $('ul.infolist li')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
@@ -108,9 +108,9 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const rootURL = 'http://rsj.taiyuan.gov.cn/';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const categoryID = ctx.params.caty;
|
||||
const page = ctx.params.page ?? '1';
|
||||
const categoryID = ctx.req.param('caty');
|
||||
const page = ctx.req.param('page') ?? '1';
|
||||
|
||||
const pageParam = Number.parseInt(page) > 1 ? `_${page}` : '';
|
||||
const pagePath = `/zfxxgk/${categoryID}/index${pageParam}.shtml`;
|
||||
@@ -19,7 +19,7 @@ module.exports = async (ctx) => {
|
||||
throw new Error(response.statusMessage);
|
||||
}
|
||||
|
||||
const $ = cheerio.load(response.data, { decodeEntities: false });
|
||||
const $ = load(response.data, { decodeEntities: false });
|
||||
const title = $('.tit').find('a:eq(2)').text();
|
||||
const list = $('.RightSide_con ul li')
|
||||
.map((_, item) => {
|
||||
@@ -33,9 +33,9 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '太原市人力资源和社会保障局 - ' + title,
|
||||
link: currentURL.href,
|
||||
item: list,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'http://www.wuhan.gov.cn';
|
||||
const currentUrl = `${rootUrl}/sy/whyw/`;
|
||||
const response = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
const list = $('.articleList li')
|
||||
.toArray()
|
||||
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
item.description = content('.view').html();
|
||||
item.author = content('meta[name=ContentSource]').attr('content');
|
||||
@@ -36,9 +36,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `${$('h2').text()} - 武汉市人民政府`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? '';
|
||||
const category = ctx.req.param('category') ?? '';
|
||||
|
||||
const rootUrl = 'http://hrss.xz.gov.cn';
|
||||
const currentUrl = `${rootUrl}${category ? `/001/${category}/subPage.html` : ''}`;
|
||||
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
let items = (category ? $('.module-items a') : $('.bdl[data-target="1"]').eq(1).find('a')).toArray().map((item) => {
|
||||
item = $(item);
|
||||
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
item.description = content('#Zoom, .mian-cont, .ewb-article-info, #UCAP-CONTENT').html();
|
||||
item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').attr('content')), +8);
|
||||
@@ -46,9 +46,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `徐州市人力资源和社会保障局 - ${category ? $('.wb-tree-items.current').text() : '通知公告'}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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 { category, column } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 50;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 50;
|
||||
|
||||
const rootUrl = 'http://gwy.zjks.gov.cn';
|
||||
const currentUrl = new URL(`zjgwy/website/${category ? 'queryMore' : 'init'}.htm`, rootUrl).href;
|
||||
@@ -18,7 +18,7 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
let items = $('a[onclick^="queryDetail"]')
|
||||
.slice(0, limit)
|
||||
@@ -50,7 +50,7 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
|
||||
item.description = content('div.ibox-content').last().html();
|
||||
item.category = [content('div.ibox-title').last().find('h5').first().text()];
|
||||
@@ -72,7 +72,7 @@ module.exports = async (ctx) => {
|
||||
const columnName = $('button.btn-success').last().text();
|
||||
const categoryName = $('table').parent().prev().find('h5').text();
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: `${$('title').text()} - ${columnName}${categoryName}`,
|
||||
link: currentUrl,
|
||||
@@ -80,5 +80,5 @@ module.exports = async (ctx) => {
|
||||
subtitle: `${columnName}${categoryName}`,
|
||||
author: $('div.title-font').text(),
|
||||
allowEmpty: true,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { advance } = ctx.params;
|
||||
@@ -16,7 +16,7 @@ module.exports = async (ctx) => {
|
||||
const res = await got.get(link, {
|
||||
searchParams: query.replaceAll(/([\u4E00-\u9FA5])/g, (str) => encodeURIComponent(str)),
|
||||
});
|
||||
const $ = cheerio.load(res.data);
|
||||
const $ = load(res.data);
|
||||
|
||||
const list = $('body > div.dataBox > table > tbody > tr')
|
||||
.slice(1)
|
||||
@@ -36,7 +36,7 @@ module.exports = async (ctx) => {
|
||||
let description = '';
|
||||
try {
|
||||
const contentData = await got(item.link);
|
||||
const $ = cheerio.load(contentData.data);
|
||||
const $ = load(contentData.data);
|
||||
description = $('#UCAP-CONTENT').html();
|
||||
} catch {
|
||||
description = '文章已被删除';
|
||||
@@ -47,9 +47,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '信息稿件 - 中国政府网',
|
||||
link: `${link}?${query}`,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { category = 'zuixin' } = ctx.params;
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 20;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20;
|
||||
|
||||
const rootUrl = 'https://www.gov.cn';
|
||||
const currentUrl = new URL(`zhengce/${category.replace(/\/$/, '')}/`, rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
let items = $('h4 a, div.subtitle a[title]')
|
||||
.toArray()
|
||||
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
const content = load(detailResponse);
|
||||
|
||||
const processElementText = (el) => content(el).text().split(/:/).pop().trim() || content(el).next().text().trim();
|
||||
|
||||
@@ -84,7 +84,7 @@ module.exports = async (ctx) => {
|
||||
const subtitle = $('meta[name="lanmu"]').prop('content');
|
||||
const author = $('div.header_logo a[aria-label]').prop('aria-label');
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
item: items,
|
||||
title: author && subtitle ? `${author} - ${subtitle}` : $('title').text(),
|
||||
link: currentUrl,
|
||||
@@ -95,5 +95,5 @@ module.exports = async (ctx) => {
|
||||
logo: icon,
|
||||
subtitle,
|
||||
author,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { pcodeJiguan } = ctx.params;
|
||||
const link = 'http://sousuo.gov.cn/list.htm';
|
||||
const res = await got(link, {
|
||||
searchParams: {
|
||||
n: ctx.query.limit ? Number(ctx.query.limit) : 20,
|
||||
n: ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 20,
|
||||
sort: 'pubtime',
|
||||
t: 'paper',
|
||||
pcodeJiguan: pcodeJiguan ?? '',
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(res.data);
|
||||
const $ = load(res.data);
|
||||
|
||||
const list = $('body > div.dataBox > table > tbody > tr')
|
||||
.slice(1)
|
||||
@@ -32,16 +32,16 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const contentData = await got(item.link);
|
||||
const $ = cheerio.load(contentData.data);
|
||||
const $ = load(contentData.data);
|
||||
item.description = $('#UCAP-CONTENT').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '最新文件 - 中国政府网',
|
||||
link: res.url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const buildData = require('@/utils/common-config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const department = ctx.params.department;
|
||||
const department = ctx.req.param('department');
|
||||
const link = `http://www.gov.cn/zhengce/zhengceku/${department}/`;
|
||||
|
||||
ctx.state.data = await buildData({
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
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 script = ctx.params.script;
|
||||
const script = ctx.req.param('script');
|
||||
const rootUrl = 'https://greasyfork.org';
|
||||
const currentUrl = `${rootUrl}/scripts/${script}/feedback`;
|
||||
const response = await got(currentUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
description: $('meta[name=description]').attr('content'),
|
||||
@@ -27,5 +27,5 @@ module.exports = async (ctx) => {
|
||||
link: rootUrl + discussionTitle.attr('href'),
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
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 language = ctx.params.language === 'all' ? 'zh-CN' : ctx.params.language || 'zh-CN';
|
||||
const domain = ctx.params.domain;
|
||||
const filter_locale = ctx.params.language === 'all' ? 0 : 1;
|
||||
const sort = ctx.params.sort ?? 'updated';
|
||||
const language = ctx.req.param('language') === 'all' ? 'zh-CN' : ctx.req.param('language') || 'zh-CN';
|
||||
const domain = ctx.req.param('domain');
|
||||
const filter_locale = ctx.req.param('language') === 'all' ? 0 : 1;
|
||||
const sort = ctx.req.param('sort') ?? 'updated';
|
||||
const url = domain ? `/by-site/${domain}` : '';
|
||||
const currentUrl = `https://greasyfork.org/${language}/scripts${url}`;
|
||||
const res = await got({
|
||||
@@ -17,10 +17,10 @@ module.exports = async (ctx) => {
|
||||
sort,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(res.data);
|
||||
const $ = load(res.data);
|
||||
const list = $('.script-list').find('article');
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('title').first().text(),
|
||||
link: currentUrl,
|
||||
description: $('meta[name=description]').attr('content'),
|
||||
@@ -40,5 +40,5 @@ module.exports = async (ctx) => {
|
||||
.join(', '),
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
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 script = ctx.params.script;
|
||||
const script = ctx.req.param('script');
|
||||
const currentUrl = `https://greasyfork.org/scripts/${script}/versions`;
|
||||
const response = await got(currentUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
description: $('meta[name=description]').attr('content'),
|
||||
@@ -25,5 +25,5 @@ module.exports = async (ctx) => {
|
||||
link: versionNumberLink.attr('href'),
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const { getData, getList } = require('./utils');
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://grist.org/';
|
||||
const { data: response } = await got(baseUrl);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const listItems = $('li.hp-featured__tease')
|
||||
.toArray()
|
||||
@@ -19,7 +19,7 @@ module.exports = async (ctx) => {
|
||||
const itemData = await Promise.all(listItems.map((item) => ctx.cache.tryGet(item.link, async () => (await getData(`https://grist.org/wp-json/wp/v2/posts?slug='${item.link}'&_embed`))[0])));
|
||||
const items = await getList(itemData);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: 'Gist Featured Articles',
|
||||
link: baseUrl,
|
||||
item: items,
|
||||
@@ -27,5 +27,5 @@ module.exports = async (ctx) => {
|
||||
logo: 'https://grist.org/wp-content/uploads/2021/03/cropped-Grist-Favicon.png?w=192',
|
||||
icon: 'https://grist.org/wp-content/uploads/2021/03/cropped-Grist-Favicon.png?w=32',
|
||||
language: 'en-us',
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ module.exports = async (ctx) => {
|
||||
const data = await getData(`${baseUrl}${route}`);
|
||||
const items = await getList(data);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: 'Gist Latest Articles',
|
||||
link: `${baseUrl}/articles`,
|
||||
item: items,
|
||||
@@ -15,5 +15,5 @@ module.exports = async (ctx) => {
|
||||
logo: 'https://grist.org/wp-content/uploads/2021/03/cropped-Grist-Favicon.png?w=192',
|
||||
icon: 'https://grist.org/wp-content/uploads/2021/03/cropped-Grist-Favicon.png?w=32',
|
||||
language: 'en-us',
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
|
||||
const data = await getData(`${baseUrl}${articleRoute}${id}&_embed`);
|
||||
const items = await getList(data);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `${series[0].toUpperCase() + series.slice(1)} - Gist Articles`,
|
||||
link: `${baseUrl}/${series}`,
|
||||
item: items,
|
||||
@@ -17,5 +17,5 @@ module.exports = async (ctx) => {
|
||||
logo: 'https://grist.org/wp-content/uploads/2021/03/cropped-Grist-Favicon.png?w=192',
|
||||
icon: 'https://grist.org/wp-content/uploads/2021/03/cropped-Grist-Favicon.png?w=32',
|
||||
language: 'en-us',
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
|
||||
const data = await getData(`${baseUrl}${articleRoute}${id}&_embed`);
|
||||
const items = await getList(data);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `${topic[0].toUpperCase() + topic.slice(1)} - Gist Articles`,
|
||||
link: `${baseUrl}/${topic}`,
|
||||
item: items,
|
||||
@@ -17,5 +17,5 @@ module.exports = async (ctx) => {
|
||||
logo: 'https://grist.org/wp-content/uploads/2021/03/cropped-Grist-Favicon.png?w=192',
|
||||
icon: 'https://grist.org/wp-content/uploads/2021/03/cropped-Grist-Favicon.png?w=32',
|
||||
language: 'en-us',
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const getData = (url) => got.get(url).json();
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
async function load(link) {
|
||||
async function loadContent(link) {
|
||||
const response = await got(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
const description = $('div.article-content');
|
||||
|
||||
@@ -53,7 +53,7 @@ function ProcessFeed(list, caches) {
|
||||
single.author = bylineString;
|
||||
}
|
||||
|
||||
const { description } = await load(itemUrl);
|
||||
const { description } = await loadContent(itemUrl);
|
||||
single.description = description;
|
||||
|
||||
return single;
|
||||
@@ -68,7 +68,7 @@ const getData = async (ctx, url, title, description) => {
|
||||
const data = response.data;
|
||||
|
||||
// limit the list to only 25 articles, to make sure that load times remain reasonable
|
||||
const list = data.articles.slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 25);
|
||||
const list = data.articles.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 25);
|
||||
const result = await ProcessFeed(list, ctx.cache);
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.guancha.cn';
|
||||
@@ -12,7 +12,7 @@ module.exports = async (ctx) => {
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
let items = $('.headline-list li .content-headline h3 a')
|
||||
.toArray()
|
||||
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
item.description += content('.all-txt').html();
|
||||
|
||||
@@ -43,9 +43,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '观察者网 - 头条',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
+9
-10
@@ -1,8 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate, parseRelativeDate } from '@/utils/parse-date';
|
||||
|
||||
const config = {
|
||||
review: {
|
||||
@@ -36,7 +35,7 @@ const config = {
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const total = 10;
|
||||
const category = ctx.params.category ?? 'all';
|
||||
const category = ctx.req.param('category') ?? 'all';
|
||||
const rootUrl = 'https://www.guancha.cn';
|
||||
|
||||
let newsList = [],
|
||||
@@ -51,7 +50,7 @@ module.exports = async (ctx) => {
|
||||
url: rootUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
const fetchPost = (slice) =>
|
||||
slice
|
||||
@@ -130,7 +129,7 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
}
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
const dateMatch = detailResponse.data.match(/"pubDate": "(.*)"/);
|
||||
item.pubDate =
|
||||
@@ -145,9 +144,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `观察者网 - ${config[category].title}`,
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const got = require('@/utils/got');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const titles = {
|
||||
recommend: '精选',
|
||||
@@ -10,7 +10,7 @@ const titles = {
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'recommend';
|
||||
const category = ctx.req.param('category') ?? 'recommend';
|
||||
|
||||
const rootUrl = 'https://member.guancha.cn';
|
||||
const apiUrl = `${rootUrl}/zaixianke/home`;
|
||||
@@ -78,9 +78,9 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `观学院 - ${titles[category]}`,
|
||||
link: `${rootUrl}/index.html`,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
import got from '@/utils/got';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const uid = ctx.params.uid;
|
||||
const uid = ctx.req.param('uid');
|
||||
const host = 'https://user.guancha.cn';
|
||||
const link = `https://app.guancha.cn/user/get-published-list?page_size=20&page_no=1&uid=${uid}`;
|
||||
const response = await got({
|
||||
@@ -57,7 +57,7 @@ module.exports = async (ctx) => {
|
||||
}
|
||||
return time;
|
||||
}
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `${user_nick}-观察者-风闻社区`,
|
||||
link,
|
||||
description: `${user_nick} 的个人主页`,
|
||||
@@ -68,5 +68,5 @@ module.exports = async (ctx) => {
|
||||
link: `https://user.guancha.cn/main/content?id=${item.id}`,
|
||||
author: item.user_nick,
|
||||
})),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseRelativeDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id ?? '0';
|
||||
const order = ctx.params.order ?? '1';
|
||||
const id = ctx.req.param('id') ?? '0';
|
||||
const order = ctx.req.param('order') ?? '1';
|
||||
|
||||
const rootUrl = 'https://user.guancha.cn';
|
||||
const currentUrl = `${rootUrl}/${id === '0' ? 'main/index-list.json?' : 'topic/post-list?topic_id=' + id}&page=1&order=${order}`;
|
||||
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
let items = $('.list-item h4 a, ul.home li .list-item h4 a')
|
||||
.toArray()
|
||||
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
item.pubDate = parseRelativeDate(content('.time1').text());
|
||||
item.author = content('.user-main h4 a').first().text();
|
||||
@@ -48,9 +48,9 @@ module.exports = async (ctx) => {
|
||||
|
||||
$('h1.title span').remove();
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `观察者网 - ${id === '0' ? '风闻' : $('h1.title').text()}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseRelativeDate } from '@/utils/parse-date';
|
||||
|
||||
const host = 'https://guangdiu.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const query = ctx.params.query ?? '';
|
||||
const query = ctx.req.param('query') ?? '';
|
||||
const url = `${host}/cheaps.php${query ? `?${query}` : ''}`;
|
||||
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
const items = $('div.cheapitem.rightborder')
|
||||
.map((_index, item) => ({
|
||||
@@ -20,9 +20,9 @@ module.exports = async (ctx) => {
|
||||
}))
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `逛丢 - 九块九`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseRelativeDate } from '@/utils/parse-date';
|
||||
|
||||
const host = 'https://guangdiu.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const query = ctx.params.query ?? '';
|
||||
const query = ctx.req.param('query') ?? '';
|
||||
const url = query === 'c=us' ? `${host}/?c=us` : `${host}/${query ? `cate.php?${query}` : ''}`;
|
||||
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const list = $('#mainleft > div.zkcontent > div.gooditem')
|
||||
.map((_index, item) => ({
|
||||
title: $(item).find('a.goodname').text().trim(),
|
||||
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const $ = cheerio.load(detailResponse.data);
|
||||
const $ = load(detailResponse.data);
|
||||
|
||||
item.description = $('#dabstract').html() + $('a.dgotobutton').html('前往购买');
|
||||
item.pubDate = parseRelativeDate($('span.latesttime').text());
|
||||
@@ -31,9 +31,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `逛丢 - ${query.includes('c=us') ? '海外' : '国内'}`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseRelativeDate } from '@/utils/parse-date';
|
||||
|
||||
const host = 'https://guangdiu.com';
|
||||
|
||||
@@ -8,7 +8,7 @@ module.exports = async (ctx) => {
|
||||
const url = `${host}/rank.php`;
|
||||
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const list = $('div.hourrankitem')
|
||||
.map((_index, item) => ({
|
||||
title: $(item).find('a.hourranktitle').text(),
|
||||
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const $ = cheerio.load(detailResponse.data);
|
||||
const $ = load(detailResponse.data);
|
||||
|
||||
item.description = $('#dabstract').html() + $('a.dgotobutton').html('前往购买');
|
||||
item.pubDate = parseRelativeDate($('div.hourranktime').text());
|
||||
@@ -30,9 +30,9 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `逛丢 - 一小时风云榜`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseRelativeDate } from '@/utils/parse-date';
|
||||
|
||||
const host = 'https://guangdiu.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const query = ctx.params.query ?? '';
|
||||
const query = ctx.req.param('query') ?? '';
|
||||
const url = `${host}/${query ? `search.php?${query}` : ''}`;
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const list = $('#mainleft > div.zkcontent > div.gooditem')
|
||||
.map((_index, item) => ({
|
||||
title: $(item).find('a.goodname').text().trim(),
|
||||
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const $ = cheerio.load(detailResponse.data);
|
||||
const $ = load(detailResponse.data);
|
||||
|
||||
item.description = $('#dabstract').html() + $('a.dgotobutton').html('前往购买');
|
||||
item.pubDate = parseRelativeDate($('span.latesttime').text());
|
||||
@@ -32,9 +32,9 @@ module.exports = async (ctx) => {
|
||||
|
||||
const match = /q=(.+)/.exec(query);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `逛丢 - ${match[1]}`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
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 newsUrl = 'https://www.gzmtr.com/ygwm/xwzx/gsxw/';
|
||||
const response = await got(newsUrl);
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const $ = load(data);
|
||||
const list = $('ul.ag_h_w li')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '广州地铁新闻',
|
||||
url: newsUrl,
|
||||
description: '广州地铁新闻',
|
||||
@@ -33,5 +33,5 @@ module.exports = async (ctx) => {
|
||||
link: item.link,
|
||||
author: item.author,
|
||||
})),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { data: response } = await got('https://www.guanhai.com.cn');
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const recommand = $('.img-box ul > a')
|
||||
.toArray()
|
||||
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
item.author = $('.source').text();
|
||||
item.description = $('.article-content').html() ?? $('.video-content').html();
|
||||
item.pubDate = item.pubDate ?? timezone(parseDate($('.date').text(), 'YYYY-MM-DD HH:mm'), 8);
|
||||
@@ -44,11 +44,11 @@ module.exports = async (ctx) => {
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: $('head title').text(),
|
||||
description: $('head meta[name=description]').text(),
|
||||
image: 'https://www.guanhai.com.cn/favicon.ico',
|
||||
link: 'https://www.guanhai.com.cn',
|
||||
item: items,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const got = require('@/utils/got');
|
||||
import got from '@/utils/got';
|
||||
const dayjs = require('dayjs');
|
||||
const { art } = require('@/utils/render');
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
|
||||
const host = 'http://data.guduodata.com';
|
||||
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
|
||||
url: `${host}/show/datalist?type=DAILY&category=${category.toUpperCase()}&date=${yestoday}`,
|
||||
}))
|
||||
);
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `骨朵数据 - 日榜`,
|
||||
link: host,
|
||||
description: yestoday,
|
||||
@@ -59,5 +59,5 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
)
|
||||
),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { art } = require('@/utils/render');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { art } from '@/utils/render';
|
||||
const path = require('path');
|
||||
const { isValidHost } = require('@/utils/valid-host');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const username = ctx.params.username;
|
||||
const products = ctx.params.products;
|
||||
const username = ctx.req.param('username');
|
||||
const products = ctx.req.param('products');
|
||||
if (!isValidHost(username)) {
|
||||
throw new Error('Invalid username');
|
||||
}
|
||||
const url = `https://${username}.gumroad.com/l/${products}`;
|
||||
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const title = $('section.product-content.product-content__row > header > h1').text();
|
||||
const userFullName = $('section.product-content.product-content__row > section.details > a').text();
|
||||
|
||||
@@ -31,9 +31,9 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
];
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
link: url,
|
||||
title: `Gumroad - ${userFullName}/${title}`,
|
||||
item,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const got = require('@/utils/got');
|
||||
import got from '@/utils/got';
|
||||
|
||||
async function loadFullPage(ctx, id) {
|
||||
const link = `https://apis.guokr.com/minisite/article/${id}.json`;
|
||||
@@ -17,7 +17,7 @@ const channelMap = {
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const channel = channelMap[ctx.params.channel] ?? ctx.params.channel;
|
||||
const channel = channelMap[ctx.req.param('channel')] ?? ctx.req.param('channel');
|
||||
|
||||
const response = await got(`https://www.guokr.com/apis/minisite/article.json?retrieve_type=by_wx&channel_key=${channel}&offset=0&limit=10`);
|
||||
const items = response.data.result;
|
||||
@@ -39,9 +39,9 @@ module.exports = async (ctx) => {
|
||||
}))
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `果壳网 ${channel_name}`,
|
||||
link: channel_url,
|
||||
item: result,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got('https://www.guokr.com/apis/minisite/article.json?retrieve_type=by_subject&limit=20&offset=0');
|
||||
|
||||
const result = response.data.result;
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '果壳网 科学人',
|
||||
link: 'https://www.guokr.com/scientific',
|
||||
description: '果壳网 科学人',
|
||||
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
|
||||
result.map((item) =>
|
||||
ctx.cache.tryGet(item.url, async () => {
|
||||
const res = await got(item.url);
|
||||
const $ = cheerio.load(res.data);
|
||||
const $ = load(res.data);
|
||||
item.description = $('.eflYNZ #js_content').css('visibility', 'visible').html() ?? $('.bxHoEL').html();
|
||||
return {
|
||||
title: item.title,
|
||||
@@ -26,5 +26,5 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
)
|
||||
),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
+2
-2
@@ -10,9 +10,9 @@ module.exports = async (ctx) => {
|
||||
date: '.timestyle55269',
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '广西民族大学人工智能学院 -- 通知公告',
|
||||
link: url,
|
||||
item: out,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user