fix(route): /zhihu/people/activities/:id (#10877)

* api/v3/moments -> api/v4/web_moments

* fix: tag not closing properly
This commit is contained in:
shiningdracon 2022-09-24 08:23:31 -07:00 committed by GitHub
parent 3119ebda4d
commit e48187f80a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -33,7 +33,7 @@ module.exports = async (ctx) => {
const cookie = `d_c0=${cookie_mes}`;
// second: get real data from zhihu
const apiPath = `/api/v3/moments/${id}/activities?limit=7&desktop=true`;
const apiPath = `/api/v4/web_moments/${id}/activities?limit=7&desktop=true`;
// calculate x-zse-96, refer to https://github.com/srx-2000/spider_collection/issues/18
const f = `101_3_2.0+${apiPath}+${cookie_mes}`;
@ -42,7 +42,7 @@ module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: `https://www.zhihu.com/api/v3/moments/${id}/activities?limit=7&desktop=true`,
url: `https://www.zhihu.com/api/v4/web_moments/${id}/activities?limit=7&desktop=true`,
headers: {
...utils.header,
..._header,

View File

@ -6,12 +6,21 @@ module.exports = {
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36',
},
ProcessImage(content) {
const $ = cheerio.load(content, { xmlMode: true });
const $ = cheerio.load(content, null, false);
$('noscript').remove();
$('a[data-draft-type="mcn-link-card"]').remove();
$('a').each((_, elem) => {
const href = $(elem).attr('href');
if (href.startsWith('https://link.zhihu.com/?target=')) {
const url = new URL(href);
const target = url.searchParams.get('target');
$(elem).attr('href', decodeURIComponent(target));
}
});
$('img.content_image, img.origin_image, img.content-image, img.data-actualsrc, figure>img').each((i, e) => {
if (e.attribs['data-actualsrc']) {
$(e).attr({