fix(utils): 修复抓取微信已删除文章时遇到的报错 (#9589)
* fix(utils): 支持微信公众号单图片文章抓取 * fix(utils): 支持输出微信公众号转载文章阅读原文链接 * fix(utils): 修复抓取微信已删除文章时遇到的报错 * refactor: migrate to v2 Co-authored-by: blankyu(于海洋) <blankyu@tencent.com>
This commit is contained in:
@@ -3447,14 +3447,6 @@ wechat-feeds 来源[已停止更新](https://github.com/hellodword/wechat-feeds/
|
||||
|
||||
</Route>
|
||||
|
||||
### 公众平台系统公告栏目
|
||||
|
||||
<Route author="xyqfer" example="/wechat/announce" path="/wechat/announce" />
|
||||
|
||||
### 小程序插件
|
||||
|
||||
<Route author="xyqfer" example="/wechat/miniprogram/plugins" path="/wechat/miniprogram/plugins" />
|
||||
|
||||
## 维基百科
|
||||
|
||||
### 中国大陆新闻动态
|
||||
|
||||
@@ -1036,6 +1036,10 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
## 微信小程序
|
||||
|
||||
### 公众平台系统公告栏目
|
||||
|
||||
<Route author="xyqfer" example="/wechat/announce" path="/wechat/announce" />
|
||||
|
||||
### 基础库更新日志
|
||||
|
||||
<Route author="magicLaLa nczitzk" example="/weixin/miniprogram/framework" path="/weixin/miniprogram/framework"/>
|
||||
@@ -1044,6 +1048,10 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
<Route author="nczitzk" example="/weixin/miniprogram/devtools" path="/weixin/miniprogram/devtools"/>
|
||||
|
||||
### 小程序插件
|
||||
|
||||
<Route author="xyqfer" example="/wechat/miniprogram/plugins" path="/wechat/miniprogram/plugins" />
|
||||
|
||||
### 云开发更新日志
|
||||
|
||||
<Route author="nczitzk" example="/weixin/miniprogram/wxcloud/cloud-sdk" path="/weixin/miniprogram/wxcloud/:caty?" :paramsDesc="['日志分类']">
|
||||
|
||||
+11
-13
@@ -421,20 +421,18 @@ router.get('/tucaoqq/post/:project/:key', lazyloadRouteHandler('./routes/tencent
|
||||
// Bugly SDK
|
||||
router.get('/bugly/changelog/:platform', lazyloadRouteHandler('./routes/tencent/bugly/changelog'));
|
||||
|
||||
// wechat
|
||||
router.get('/wechat/wemp/:id', lazyloadRouteHandler('./routes/tencent/wechat/wemp'));
|
||||
router.get('/wechat/csm/:id', lazyloadRouteHandler('./routes/tencent/wechat/csm'));
|
||||
router.get('/wechat/ce/:id', lazyloadRouteHandler('./routes/tencent/wechat/ce'));
|
||||
router.get('/wechat/announce', lazyloadRouteHandler('./routes/tencent/wechat/announce'));
|
||||
// wechat migrated to v2
|
||||
// router.get('/wechat/wemp/:id', lazyloadRouteHandler('./routes/tencent/wechat/wemp'));
|
||||
// router.get('/wechat/ce/:id', lazyloadRouteHandler('./routes/tencent/wechat/ce'));
|
||||
// router.get('/wechat/announce', lazyloadRouteHandler('./routes/tencent/wechat/announce'));
|
||||
router.get('/wechat/miniprogram/plugins', lazyloadRouteHandler('./routes/tencent/wechat/miniprogram/plugins'));
|
||||
router.get('/wechat/tgchannel/:id/:mpName?/:searchQueryType?', lazyloadRouteHandler('./routes/tencent/wechat/tgchannel'));
|
||||
router.get('/wechat/uread/:userid', lazyloadRouteHandler('./routes/tencent/wechat/uread'));
|
||||
router.get('/wechat/ershicimi/:id', lazyloadRouteHandler('./routes/tencent/wechat/ershcimi'));
|
||||
router.get('/wechat/wjdn/:id', lazyloadRouteHandler('./routes/tencent/wechat/wjdn'));
|
||||
router.get('/wechat/wxnmh/:id', lazyloadRouteHandler('./routes/tencent/wechat/wxnmh'));
|
||||
router.get('/wechat/mp/homepage/:biz/:hid/:cid?', lazyloadRouteHandler('./routes/tencent/wechat/mp'));
|
||||
router.get('/wechat/mp/msgalbum/:biz/:aid', lazyloadRouteHandler('./routes/tencent/wechat/msgalbum'));
|
||||
router.get('/wechat/feeds/:id', lazyloadRouteHandler('./routes/tencent/wechat/feeds'));
|
||||
// router.get('/wechat/tgchannel/:id/:mpName?/:searchQueryType?', lazyloadRouteHandler('./routes/tencent/wechat/tgchannel'));
|
||||
// router.get('/wechat/uread/:userid', lazyloadRouteHandler('./routes/tencent/wechat/uread'));
|
||||
// router.get('/wechat/ershicimi/:id', lazyloadRouteHandler('./routes/tencent/wechat/ershcimi'));
|
||||
// router.get('/wechat/wxnmh/:id', lazyloadRouteHandler('./routes/tencent/wechat/wxnmh'));
|
||||
// router.get('/wechat/mp/homepage/:biz/:hid/:cid?', lazyloadRouteHandler('./routes/tencent/wechat/mp'));
|
||||
// router.get('/wechat/mp/msgalbum/:biz/:aid', lazyloadRouteHandler('./routes/tencent/wechat/msgalbum'));
|
||||
// router.get('/wechat/feeds/:id', lazyloadRouteHandler('./routes/tencent/wechat/feeds'));
|
||||
|
||||
// All the Flight Deals
|
||||
router.get('/atfd/:locations/:nearby?', lazyloadRouteHandler('./routes/atfd/index'));
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Make sure you read lib/utils/wechat-mp.js before adding a new route.
|
||||
@@ -1,5 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `https://developers.weixin.qq.com/miniprogram/dev/framework/release/`;
|
||||
@@ -16,14 +18,14 @@ module.exports = async (ctx) => {
|
||||
ctx.state.data = {
|
||||
title: name,
|
||||
link,
|
||||
item: $('#docContent .content h3')
|
||||
item: $('#docContent .content h2')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const title = item.text().replace(/[\s|#]/g, '');
|
||||
return {
|
||||
title,
|
||||
description: item.next().html(),
|
||||
pubDate: new Date(new RegExp(/\d{4}-\d{2}-\d{2}/).exec(title) + ' GMT+8').toUTCString(),
|
||||
pubDate: timezone(parseDate(new RegExp(/\d{4}-\d{2}-\d{2}/).exec(title)), +8),
|
||||
link: link + item.find('a.header-anchor').attr('href'),
|
||||
};
|
||||
})
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* Author: @Rongronggg9
|
||||
*
|
||||
* There are at least three folders which are relevant with WeChat MP (Official Account Platform / Media Platform):
|
||||
* lib/route/tencent/wechat
|
||||
* lib/v2/wechat
|
||||
* lib/v2/gzh360
|
||||
* lib/v2/sdu/cs
|
||||
@@ -181,7 +180,7 @@ const fetchArticle = async (ctx, url, bypassHostCheck = false) => {
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const title = $('meta[property="og:title"]').attr('content').replace(/\\r/g, '').replace(/\\n/g, ' ');
|
||||
const title = ($('meta[property="og:title"]').attr('content') || '').replace(/\\r/g, '').replace(/\\n/g, ' ');
|
||||
const author = $('meta[name=author]').attr('content');
|
||||
let summary = $('meta[name=description]').attr('content');
|
||||
summary = summary !== title ? summary : '';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { data: htmlString } = await got({
|
||||
@@ -20,13 +21,13 @@ module.exports = async (ctx) => {
|
||||
title: `${time} ${title}`,
|
||||
link: `https://mp.weixin.qq.com${$link.attr('href')}`,
|
||||
description: title,
|
||||
pubDate: new Date(time).toUTCString(),
|
||||
pubDate: parseDate(time),
|
||||
});
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: '微信公众平台-系统公告栏目',
|
||||
link: 'https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncementlist&lang=zh_CN&token=',
|
||||
link: 'https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncementlist&lang=zh_CN',
|
||||
item: announceList,
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,14 @@
|
||||
module.exports = {
|
||||
'/feeddd/:id': ['TonyRL', 'Rongronggg9'],
|
||||
'/announce': ['xyqfer'],
|
||||
'/ce/:id': ['HenryQW'],
|
||||
'/ershicimi/:id': ['sanmmm'],
|
||||
'/data258/:id?': ['Rongronggg9'],
|
||||
'/feeddd/:id': ['TonyRL', 'Rongronggg9'],
|
||||
'/feeds': ['tylinux'],
|
||||
'/mp/homepage/:biz/:hid/:cid?': ['MisteryMonster'],
|
||||
'/mp/msgalbum/:biz/:aid': ['MisteryMonster'],
|
||||
'/tgchannel/:id/:mpName?/:searchQueryType?': ['LogicJake', 'Rongronggg9'],
|
||||
'/uread/:userid': ['kt286'],
|
||||
'/wemp/:id': ['HenryQW'],
|
||||
'/wxnmh/:id': ['laampui'],
|
||||
};
|
||||
|
||||
+68
-4
@@ -1,11 +1,23 @@
|
||||
module.exports = {
|
||||
'feeddd.org': {
|
||||
'careerengine.us': {
|
||||
_name: '微信',
|
||||
posts: [
|
||||
{
|
||||
title: '公众号(CareerEngine 来源)',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#wei-xin',
|
||||
source: ['/author/*id/posts'],
|
||||
target: (params) => `/wechat/ce/${params.id}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
'cimidata.com': {
|
||||
_name: '微信',
|
||||
'.': [
|
||||
{
|
||||
title: '公众号 (feeddd 来源)',
|
||||
title: '公众号(二十次幂来源)',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#wei-xin',
|
||||
source: ['/'],
|
||||
source: ['/a/:id'],
|
||||
target: '/wechat/ce/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -13,11 +25,63 @@ module.exports = {
|
||||
_name: '微信',
|
||||
mp: [
|
||||
{
|
||||
title: '公众号 (微阅读来源)',
|
||||
title: '公众号(微阅读来源)',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#wei-xin',
|
||||
source: ['/', '/article/category/:id'],
|
||||
target: '/wechat/data258/:id?',
|
||||
},
|
||||
],
|
||||
},
|
||||
'feeddd.org': {
|
||||
_name: '微信',
|
||||
'.': [
|
||||
{
|
||||
title: '公众号(feeddd 来源)',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#wei-xin',
|
||||
source: ['/'],
|
||||
},
|
||||
],
|
||||
},
|
||||
'mp.weixin.qq.com': {
|
||||
_name: '微信',
|
||||
'.': [
|
||||
{
|
||||
title: '公众平台系统公告栏目',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#wei-xin',
|
||||
source: ['/cgi-bin/announce'],
|
||||
target: '/wechat/announce',
|
||||
},
|
||||
],
|
||||
},
|
||||
'privacyhide.com': {
|
||||
_name: '微信',
|
||||
wechat: [
|
||||
{
|
||||
title: '公众号(wechat-feeds 来源)',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#wei-xin',
|
||||
},
|
||||
],
|
||||
},
|
||||
'wemp.app': {
|
||||
_name: '微信',
|
||||
'.': [
|
||||
{
|
||||
title: '公众号(wemp.app 来源)',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#wei-xin',
|
||||
source: ['/accounts/:id'],
|
||||
target: '/wechat/wemp/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
'wxnmh.com': {
|
||||
_name: '微信',
|
||||
'.': [
|
||||
{
|
||||
title: '公众号(wxnmh.com 来源)',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#wei-xin',
|
||||
source: ['/:id'],
|
||||
target: (params) => `/wechat/wxnmh/${params.id.replace('user-', '').replace('.htm', '')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
+11
-1
@@ -1,4 +1,14 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/feeddd/:id', require('./feeddd'));
|
||||
router.get('/announce', require('./announce'));
|
||||
router.get('/ce/:id', require('./ce'));
|
||||
router.get('/data258/:id?', require('./data258'));
|
||||
router.get('/ershicimi/:id', require('./ershcimi'));
|
||||
router.get('/feeddd/:id', require('./feeddd'));
|
||||
router.get('/feeds/:id', require('./feeds'));
|
||||
router.get('/mp/homepage/:biz/:hid/:cid?', require('./mp'));
|
||||
router.get('/mp/msgalbum/:biz/:aid', require('./msgalbum'));
|
||||
router.get('/tgchannel/:id/:mpName?/:searchQueryType?', require('./tgchannel'));
|
||||
router.get('/uread/:userid', require('./uread'));
|
||||
router.get('/wemp/:id', require('./wemp'));
|
||||
router.get('/wxnmh/:id', require('./wxnmh'));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user