mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 14:07:54 +08:00
feat: crawl 36kr newsflashes (#2984)
* crawl 36kr newsflashes * xueqiu hot statuses
This commit is contained in:
@@ -6,6 +6,10 @@ pageClass: routes
|
|||||||
|
|
||||||
## 36kr
|
## 36kr
|
||||||
|
|
||||||
|
### 快讯
|
||||||
|
|
||||||
|
<Route author="hillerliao" example="/36kr/newsflashes" path="/36kr/newsflashes" />
|
||||||
|
|
||||||
### 搜索文章
|
### 搜索文章
|
||||||
|
|
||||||
<Route author="xyqfer kt286" example="/36kr/search/article/ofo" path="/36kr/search/article/:keyword" :paramsDesc="['关键字']" />
|
<Route author="xyqfer kt286" example="/36kr/search/article/ofo" path="/36kr/search/article/:keyword" :paramsDesc="['关键字']" />
|
||||||
|
|||||||
@@ -751,6 +751,10 @@ pageClass: routes
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
### 热帖
|
||||||
|
|
||||||
|
<Route author="hillerliao" example="/xueqiu/hots" path="/xueqiu/hots"/>
|
||||||
|
|
||||||
## 一亩三分地
|
## 一亩三分地
|
||||||
|
|
||||||
### 主题帖
|
### 主题帖
|
||||||
|
|||||||
@@ -379,6 +379,7 @@ router.get('/xueqiu/user_stock/:id', require('./routes/xueqiu/user_stock'));
|
|||||||
router.get('/xueqiu/fund/:id', require('./routes/xueqiu/fund'));
|
router.get('/xueqiu/fund/:id', require('./routes/xueqiu/fund'));
|
||||||
router.get('/xueqiu/stock_info/:id/:type?', require('./routes/xueqiu/stock_info'));
|
router.get('/xueqiu/stock_info/:id/:type?', require('./routes/xueqiu/stock_info'));
|
||||||
router.get('/xueqiu/snb/:id', require('./routes/xueqiu/snb'));
|
router.get('/xueqiu/snb/:id', require('./routes/xueqiu/snb'));
|
||||||
|
router.get('/xueqiu/hots', require('./routes/xueqiu/hots'));
|
||||||
|
|
||||||
// Greasy Fork
|
// Greasy Fork
|
||||||
router.get('/greasyfork/:language/:domain?', require('./routes/greasyfork/scripts'));
|
router.get('/greasyfork/:language/:domain?', require('./routes/greasyfork/scripts'));
|
||||||
@@ -973,6 +974,7 @@ router.get('/tingdiantz/nanjing', require('./routes/tingdiantz/nanjing'));
|
|||||||
|
|
||||||
// 36kr
|
// 36kr
|
||||||
router.get('/36kr/search/article/:keyword', require('./routes/36kr/search/article'));
|
router.get('/36kr/search/article/:keyword', require('./routes/36kr/search/article'));
|
||||||
|
router.get('/36kr/newsflashes', require('./routes/36kr/newsflashes'));
|
||||||
|
|
||||||
// icourse163
|
// icourse163
|
||||||
router.get('/icourse163/newest', require('./routes/icourse163/newest'));
|
router.get('/icourse163/newest', require('./routes/icourse163/newest'));
|
||||||
|
|||||||
40
lib/routes/36kr/newsflashes.js
Normal file
40
lib/routes/36kr/newsflashes.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: `https://36kr.com/api/newsflash?per_page=30`,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const newsflashes = response.data.data.items;
|
||||||
|
|
||||||
|
let newsflashesList = [];
|
||||||
|
for (let i = 0; i < newsflashes.length; i++) {
|
||||||
|
newsflashesList = newsflashesList.concat(newsflashes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const out = newsflashesList.map((item) => {
|
||||||
|
const date = item.published_at;
|
||||||
|
const link = item.news_url;
|
||||||
|
const title = item.title;
|
||||||
|
const description = item.description;
|
||||||
|
|
||||||
|
const single = {
|
||||||
|
title,
|
||||||
|
link,
|
||||||
|
pubDate: new Date(date).toUTCString(),
|
||||||
|
description,
|
||||||
|
};
|
||||||
|
|
||||||
|
return single;
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `快讯 - 36氪`,
|
||||||
|
link: `https://36kr.com/newsflashes`,
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
|
|||||||
let name = '';
|
let name = '';
|
||||||
const out = announcementsList.map((item) => {
|
const out = announcementsList.map((item) => {
|
||||||
const date = item.announcementTime;
|
const date = item.announcementTime;
|
||||||
const link = `http://www.cninfo.com.cn/new/disclosure/detail?announcementId=${item.announcementId}`;
|
const link = `http://static.cninfo.com.cn/${item.adjunctUrl}`;
|
||||||
name = item.secName;
|
name = item.secName;
|
||||||
const title = name + ': ' + item.announcementTitle;
|
const title = name + ': ' + item.announcementTitle;
|
||||||
|
|
||||||
|
|||||||
42
lib/routes/xueqiu/hots.js
Normal file
42
lib/routes/xueqiu/hots.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const res1 = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: 'https://xueqiu.com/',
|
||||||
|
});
|
||||||
|
const token = res1.headers['set-cookie'].find((s) => s.startsWith('xq_a_token=')).split(';')[0];
|
||||||
|
|
||||||
|
const res2 = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: 'https://xueqiu.com/statuses/hots.json',
|
||||||
|
params: {
|
||||||
|
a: '1',
|
||||||
|
count: '10',
|
||||||
|
page: '1',
|
||||||
|
scope: 'day',
|
||||||
|
type: 'status',
|
||||||
|
meigu: '0',
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
Cookie: token,
|
||||||
|
Referer: `https://xueqiu.com/`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const data = res2.data;
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `热帖 - 雪球`,
|
||||||
|
link: `https://xueqiu.com/`,
|
||||||
|
description: `雪球热门帖子`,
|
||||||
|
item: data.map((item) => {
|
||||||
|
const description = item.text;
|
||||||
|
return {
|
||||||
|
title: item.title ? item.title : description,
|
||||||
|
description: item.text,
|
||||||
|
pubDate: new Date(item.created_at).toUTCString(),
|
||||||
|
link: `https://xueqiu.com${item.target}`,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -11,16 +11,13 @@ module.exports = async (ctx) => {
|
|||||||
|
|
||||||
const res2 = await got({
|
const res2 = await got({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: 'https://stock.xueqiu.com/v5/stock/portfolio/stock/list.json?category=1&size=1000',
|
url: `https://stock.xueqiu.com/v5/stock/portfolio/stock/list.json?category=1&size=1000&uid=${id}`,
|
||||||
params: {
|
|
||||||
uid: id,
|
|
||||||
},
|
|
||||||
headers: {
|
headers: {
|
||||||
Cookie: token,
|
Cookie: token,
|
||||||
Referer: `https://xueqiu.com/u/${id}`,
|
Referer: `https://xueqiu.com/u/${id}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const data = res2.data.stocks;
|
const data = res2.data.data.stocks;
|
||||||
|
|
||||||
const res3 = await got({
|
const res3 = await got({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
|||||||
Reference in New Issue
Block a user