Files
RSSHub/lib/v2/tingshuitz/dalian.js
T
Wildmoe eea20288d5 fix(route): 南京停水通知 (#9782)
* fix(route): 南京停水通知

* fix(route): 南京停水通知

* refactor: migrate to v2
2022-05-21 00:35:05 +08:00

30 lines
1.1 KiB
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const url =
'https://swj.dl.gov.cn/module/web/jpage/dataproxy.jsp?page=1&webid=28&path=https://swj.dl.gov.cn/&columnid=4296&unitid=31227&webname=%25E5%25A4%25A7%25E8%25BF%259E%25E5%25B8%2582%25E6%25B0%25B4%25E5%258A%25A1%25E5%25B1%2580&permissiontype=0';
const response = await got(url);
const $ = cheerio.load(response.data);
const items = $('recordset record')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('a').text().trim(),
description: `大连市停水通知:${item.find('a').text().trim()}`,
pubDate: parseDate(item.find('span').text(), 'YYYY-MM-DD'),
link: item.find('a').attr('href'),
};
});
ctx.state.data = {
title: '停水通知 - 大连市水务局',
link: 'https://swj.dl.gov.cn/col/col4296/index.html',
description: '停水通知 - 大连市水务局',
item: items,
};
};