fix: 网易云音乐提供Cookie,抓取需要登陆才可见的歌单 && 中纪委、外交部网站小变动 (#8674)
This commit is contained in:
parent
89d2a6e294
commit
37a2152723
|
|
@ -617,11 +617,11 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
|
|||
|
||||
- 端传媒设置,用于获取付费内容全文:
|
||||
|
||||
- `INITIUM_BEARER_TOKEN`: 端传媒 Web 版认证 token。获取方式:登陆后打开端传媒站内任意页面,打开浏览器开发者工具中 “网络”(Network) 选项卡,筛选 URL 找到任一个地址为`api.initium.com`开头的请求,点击检查其 “消息头”,在 “请求头” 中找到`Authorization`字段,将其值复制填入配置即可。你的配置应该形如`INITIUM_BEARER_TOKEN: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6JiE1NTYzNDgxNDVAcXEuY29tIiwidXNlcl9pZCI6MTM0NDIwLCJlbWFpbCI6IjE1NTYzNDgxNDVAcXEuY29tIiwiZXhwIjoxNTk0MTk5NjQ3fQ.Tqui-ORNR7d4Bh240nKy_Ldi6crfq0A78Yj2iwy2_U8'`。
|
||||
- `INITIUM_BEARER_TOKEN`: 端传媒 Web 版认证 token。获取方式:登陆后打开端传媒站内任意页面,打开浏览器开发者工具中 “网络”(Network) 选项卡,筛选 URL 找到任一个地址为`api.initium.com`开头的请求,点击检查其 “消息头”,在 “请求头” 中找到`Authorization`字段,将其值复制填入配置即可。你的配置应该形如`INITIUM_BEARER_TOKEN: 'Bearer eyJxxxx......xx_U8'`。使用 token 部署的好处是避免占据登陆设备数的额度,但这个 token 一般有效期为两周,因此只可作临时测试使用。
|
||||
|
||||
- `INITIUM_IAP_RECEIPT`: 端传媒 iOS 版内购回执认证 token。获取方式:登陆后打开端传媒 iOS app 内任意页面,打开抓包工具,筛选 URL 找到任一个地址为`api.initium.com`开头的请求,点击检查其 “消息头”,在 “请求头” 中找到`X-IAP-Receipt`字段,将其值复制填入配置即可。你的配置应该形如`INITIUM_IAP_RECEIPT: 'ef81dee9e4e2fe084a0af1ea82da2f7b16e75f756db321618a119fa62b52550e'`。
|
||||
|
||||
Web 版认证 token 和 iOS 内购回执认证 token 只需选择其一填入即可。如果你在进行上述操作时遇到困难,亦可选择在环境设置中填写明文的用户名和密码:
|
||||
Web 版认证 token 和 iOS 内购回执认证 token 只需选择其一填入即可。你也可选择直接在环境设置中填写明文的用户名和密码:
|
||||
|
||||
- `INITIUM_USERNAME`: 端传媒用户名 (邮箱)
|
||||
- `INITIUM_PASSWORD`: 端传媒密码
|
||||
|
|
@ -691,6 +691,10 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
|
|||
- `ZHIHU_COOKIES`: 知乎登录后的 cookie 值.
|
||||
1. 可以在知乎网页版的一些请求的请求头中找到,如 `GET /moments` 请求头中的 `cookie` 值.
|
||||
|
||||
- 网易云歌单及听歌排行
|
||||
|
||||
- `NCM_COOKIES`: 网易云音乐登陆后的 cookie 值.
|
||||
|
||||
- Wordpress
|
||||
|
||||
- `WORDPRESS_CDN`: 用于中转 http 图片链接。可供考虑的服务见下表:
|
||||
|
|
|
|||
|
|
@ -1152,6 +1152,11 @@ JavDB 有多个备用域名,本路由以 <https://javdb7.com> 为默认域名
|
|||
|
||||
## 网易云音乐
|
||||
|
||||
::: tip 部分歌单及听歌排行信息为登陆后可见
|
||||
|
||||
部分歌单及听歌排行信息为登陆后可见,自建时将环境变量`NCM_Cookies`设为登陆后的 Cookie 值,即可正常获取。
|
||||
:::
|
||||
|
||||
### 歌单歌曲
|
||||
|
||||
<Route author="DIYgod" example="/ncm/playlist/35798529" path="/ncm/playlist/:id" :paramsDesc="['歌单 id, 可在歌单页 URL 中找到']" radar="1" />
|
||||
|
|
|
|||
|
|
@ -92,6 +92,9 @@ const calculateValue = () => {
|
|||
zhihu: {
|
||||
cookies: envs.ZHIHU_COOKIES,
|
||||
},
|
||||
ncm: {
|
||||
cookies: envs.NCM_COOKIES || '',
|
||||
},
|
||||
puppeteerWSEndpoint: envs.PUPPETEER_WS_ENDPOINT,
|
||||
loggerLevel: envs.LOGGER_LEVEL || 'info',
|
||||
proxyUri: envs.PROXY_URI,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ const got = require('@/utils/got');
|
|||
const { resolve } = require('url');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'http://www.ccdi.gov.cn/scdc/';
|
||||
const url = 'https://www.ccdi.gov.cn/scdcn/';
|
||||
const res = await got.get(url);
|
||||
const $ = cheerio.load(res.data);
|
||||
|
||||
|
|
@ -27,11 +27,15 @@ module.exports = async (ctx) => {
|
|||
if (value) {
|
||||
item.description = value;
|
||||
} else {
|
||||
const response = await got.get(item.link);
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
item.description = $('div.TRS_Editor').html();
|
||||
ctx.cache.set(key, item.description);
|
||||
try {
|
||||
const response = await got.get(item.link);
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
item.description = $('div.TRS_Editor').html();
|
||||
ctx.cache.set(key, item.description);
|
||||
} catch (error) {
|
||||
item.description = '';
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
|
|
|
|||
|
|
@ -448,11 +448,16 @@ async function getFullTextItems(ctx, items) {
|
|||
if (cache) {
|
||||
item.status.reshared_status.text = cache;
|
||||
} else if (tryFixStatus(item.status.reshared_status).isFixSuccess) {
|
||||
const {
|
||||
data: { text },
|
||||
} = await got({ url, headers });
|
||||
ctx.cache.set(url, text);
|
||||
item.status.reshared_status.text = text;
|
||||
try {
|
||||
// 存在reshared_status字段正常,但尝试获取时返回403的情况。比如原po被炸号就可能这样。
|
||||
const {
|
||||
data: { text },
|
||||
} = await got({ url, headers });
|
||||
ctx.cache.set(url, text);
|
||||
item.status.reshared_status.text = text;
|
||||
} catch (err) {
|
||||
item.status.reshared_status.text += '\n[获取原动态失败]';
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ module.exports = async (ctx) => {
|
|||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.rebox_news ul li').get();
|
||||
const list = $('.newsBd ul li').get();
|
||||
|
||||
const result = await util.ProcessFeed(list, ctx.cache);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const got = require('@/utils/got');
|
||||
const config = require('@/config').value;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
|
|
@ -8,6 +9,7 @@ module.exports = async (ctx) => {
|
|||
url: 'https://music.163.com/api/v3/playlist/detail',
|
||||
headers: {
|
||||
Referer: 'https://music.163.com/',
|
||||
Cookie: config.ncm.cookies,
|
||||
},
|
||||
form: {
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
const got = require('@/utils/got');
|
||||
const config = require('@/config').value;
|
||||
|
||||
const headers = { Referer: 'https://music.163.com/' };
|
||||
const headers = {
|
||||
cookie: config.ncm.cookies,
|
||||
Referer: 'https://music.163.com/',
|
||||
};
|
||||
|
||||
function getItem(records) {
|
||||
if (!records || records.length === 0) {
|
||||
|
|
@ -37,7 +41,7 @@ function getItem(records) {
|
|||
|
||||
module.exports = async (ctx) => {
|
||||
const uid = ctx.params.uid;
|
||||
const type = ctx.params.type || 0;
|
||||
const type = parseInt(ctx.params.type) || 0;
|
||||
|
||||
const url = `http://music.163.com/api/v1/play/record?uid=${uid}&type=${type}`;
|
||||
const response = await got({ url, headers });
|
||||
|
|
|
|||
Loading…
Reference in New Issue