fix(route): sichuan/deyang 政府公开信息 (#9480)
* fead: add 雪球股票评论 * style: auto format * fix: 修复雪球评论转发时未带原文 * refactor: 微博个人时间线接入util,支持可读性优化,同时打开emoji表情展示 * route: 雪球评论标题长度自定义 * style: auto format * fix: 风之动漫域名更换 * fix: 风之漫画新域名适配 * refactor: 微博个人时间线接入util,支持可读性优化,同时打开emoji表情展示 * fix: 雪球股票评论格式调整 * fix: 风之动漫域名更换 * fix: 风之动漫link修复 * fix: 雪球股票评论正文使用art模板,日期解析调整 * feat(route): add 德阳考试中心 * feat(route): add 德阳考试中心 * fix: 风之动漫获取数量去掉限制 * fix: 风之动漫获取数量去掉限制 * fix: 风之动漫获取数量使用通用参数控制 * fix: 风之动漫获取数量使用通用参数控制 * style: auto format * fix: dykszx * fix: 德阳考试中心 ssl证书过期 * Merge branch 'master' of https://github.com/DIYgod/RSSHub into dykszx * Merge branch 'master' of https://github.com/DIYgod/RSSHub into dykszx * tmp1 * tmp2: * tmp3 * feat(route): add 政府公开信息 * feat(route): add 政府公开信息 * feat(route): add 政府公开信息 * feat(route): add 政府公开信息 * feat(route): add 政府公开信息 * Revert "feat(route): add 政府公开信息" This reverts commit c9d59af9e09b14f7357014382037b7f378d65ea7. * feat(route): add 政府公开信息 * fix: 修复德阳政府公开信息 * fix: 修复德阳政府公开信息 * Merge branch 'master' of https://github.com/DIYgod/RSSHub into fix_router * Merge branch 'master' of https://github.com/DIYgod/RSSHub into fix_router * Merge branch 'master' of https://github.com/DIYgod/RSSHub into fix_router * fix: 修复德阳政府公开信息 * fix: 修复德阳政府公开信息 * fix: 修复德阳政府公开信息 * fix(route): add ipv6 support * fix(route): add ipv6 support Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
1261a74eec
commit
e7558e88b1
|
|
@ -3,7 +3,6 @@ const cheerio = require('cheerio');
|
|||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
// 各地区url信息
|
||||
const basicInfoDict = {
|
||||
|
|
@ -16,10 +15,16 @@ const basicInfoDict = {
|
|||
const getInfoUrlList = async (countyName) => {
|
||||
const url = basicInfoDict[countyName].infoUrl;
|
||||
const infoUrlList = [];
|
||||
const expectToday = parseDate(timezone(new Date(), +8));
|
||||
const expectToday = new Date();
|
||||
for (let pageNum = 1; ; pageNum++) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const response = await got(`${url}${pageNum}`);
|
||||
let response;
|
||||
try {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
response = await got(`${url}${pageNum}`);
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
response = await got(`${url}${pageNum}`, { dnsLookupIpVersion: 'ipv6' });
|
||||
}
|
||||
const $ = cheerio.load(response.data);
|
||||
const infoList = $('#list_content > ul > li');
|
||||
// 判断当前页是否有数据
|
||||
|
|
@ -27,7 +32,7 @@ const getInfoUrlList = async (countyName) => {
|
|||
for (let infoIdx = 0; infoIdx < infoList.length; infoIdx++) {
|
||||
const date = parseDate($('span', infoList[infoIdx]).html());
|
||||
// 判断当前信息日期是否是今日
|
||||
if (date.getUTCFullYear() === expectToday.getUTCFullYear() && date.getUTCMonth() === expectToday.getUTCMonth() && date.getUTCDay() === expectToday.getUTCDay()) {
|
||||
if (date.getUTCFullYear() === expectToday.getUTCFullYear() && date.getUTCMonth() === expectToday.getUTCMonth() && date.getUTCDate() === expectToday.getUTCDate() - 1) {
|
||||
infoUrlList.push(`${basicInfoDict[countyName].rootUrl}${$('a', infoList[infoIdx]).attr('href')}`);
|
||||
} else {
|
||||
return infoUrlList;
|
||||
|
|
@ -42,7 +47,12 @@ const getInfoUrlList = async (countyName) => {
|
|||
// 获取信息正文内容
|
||||
const getInfoContent = async (ctx, url, countyName) =>
|
||||
await ctx.cache.tryGet(url, async () => {
|
||||
const response = await got(url);
|
||||
let response;
|
||||
try {
|
||||
response = await got(url);
|
||||
} catch (err) {
|
||||
response = await got(url, { dnsLookupIpVersion: 'ipv6' });
|
||||
}
|
||||
const $ = cheerio.load(response.data);
|
||||
const fileNodes = $('#symbol > div:nth-child(4) > div > span > a');
|
||||
const fileList = [];
|
||||
|
|
|
|||
Loading…
Reference in New Issue