From 7ea044a18ac8794fb8fff8b723c45a0b0b65f9bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=89=E5=87=89?= Date: Sun, 2 Jun 2019 12:42:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=81=9C=E6=B0=B4=E9=80=9A=E7=9F=A5-?= =?UTF-8?q?=E5=B9=BF=E5=B7=9E=20(#2277)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Hotifx: tingshuitz-guangzhou * 修复时间参数 --- lib/routes/tingshuitz/guangzhou.js | 37 +++++++++++------------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/lib/routes/tingshuitz/guangzhou.js b/lib/routes/tingshuitz/guangzhou.js index 8dc9f978f..43350a9e0 100644 --- a/lib/routes/tingshuitz/guangzhou.js +++ b/lib/routes/tingshuitz/guangzhou.js @@ -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}
${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, }; };