fix: 停水通知-广州 (#2277)

* Hotifx: tingshuitz-guangzhou

* 修复时间参数
This commit is contained in:
凉凉
2019-06-02 12:42:54 +08:00
committed by DIYgod
parent fbb7fa321e
commit 7ea044a18a
+13 -24
View File
@@ -1,35 +1,24 @@
const axios = require('@/utils/axios');
const cheerio = require('cheerio');
const iconv = require('iconv-lite');
module.exports = async (ctx) => {
const url = 'http://www.gzwatersupply.com/stop/stopgl.html2';
const response = await axios({
responseType: 'arraybuffer',
method: 'get',
url: url,
method: 'post',
url: `https://mp.weixin.qq.com/mp/homepage?__biz=MzA3MDE0NzAxMw%3D%3D&hid=15&sn=270abafdcf67ce4e2b52a049a0aa219a&scene=1&sharer_username=&clicktime=${Math.floor(
Date.now() / 1000
)}&devicetype=iOS12.2&version=1700042b&lang=zh_CN&nettype=WIFI&ascene=0&fontScale=100&wx_header=1&cid=0&begin=0&count=5&action=appmsg_list&f=json&r=${Math.random()}&appmsg_token=`,
});
const data = response.data;
const $ = cheerio.load(iconv.decode(data, 'gb2312'));
const list = $(
'body > table:nth-child(2) > tbody:nth-child(2) > tr > td.border3 > table:nth-child(2) > tbody > tr:nth-child(1) > td:nth-child(2) > table > tbody > tr:nth-child(3) > td > table > tbody > tr > td > table > tbody > tr:nth-child(3) > td > table > tbody > tr'
);
const items = data.appmsg_list.map(({ title, link, digest }) => ({
title,
link,
description: `${title}<br>${digest}...`,
}));
ctx.state.data = {
title: '停水通知 - 广州市自来水公司',
link: 'http://www.gzwatersupply.com/stop/stopgl.html2',
item: list
.map((index, item) => {
item = $(item);
const title = item.text();
return {
title,
description: `广州市停水通知:${title}`,
link: `http://www.gzwatersupply.com/stop/${item.find('.new2').attr('href')}`,
};
})
.get(),
title: '停水通知 - 广州市自来水96968',
link:
'https://mp.weixin.qq.com/mp/homepage?__biz=MzA3MDE0NzAxMw%3D%3D&hid=15&sn=270abafdcf67ce4e2b52a049a0aa219a&scene=1&sharer_username=&clicktime=&devicetype=iOS12.2&version=1700042b&lang=zh_CN&nettype=WIFI&ascene=0&fontScale=100&wx_header=1',
item: items,
};
};