fix(route): /zhihu/people/activities/:id (#10877)
* api/v3/moments -> api/v4/web_moments * fix: tag not closing properly
This commit is contained in:
parent
3119ebda4d
commit
e48187f80a
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Reference in New Issue