fix: facebook title, desc, images no found (#4886)
This commit is contained in:
@@ -19,10 +19,19 @@ const parseStoryPage = async (linkPath, cache) => {
|
||||
const html = await fetchPageHtml(linkPath, cacheKey, cache);
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
const title = $('h3 strong a').first().text();
|
||||
const url = `https://www.facebook.com/story.php?story_fbid=${storyFbId}&id=${storyId}`;
|
||||
const $story = $('#m_story_permalink_view').first();
|
||||
const $content = $story.find('div > div > div > div.cc');
|
||||
const $box = $story.find('div > div > div > div').eq(0);
|
||||
const $header = $box.find('header').eq(0);
|
||||
const $content = $box.find('div > div').eq(0);
|
||||
const $attach = $box.find('div > div').eq(1);
|
||||
|
||||
const attachLinkList = $attach
|
||||
.find('a')
|
||||
.toArray()
|
||||
.map((a) => $(a).attr('href'));
|
||||
const isAttachAreImageSet = attachLinkList.filter((link) => new RegExp('/photos/').test(link)).length === attachLinkList.length;
|
||||
const title = $header.find('h3').text();
|
||||
|
||||
let content = '';
|
||||
if ($content.find('p').length === 0) {
|
||||
@@ -36,11 +45,11 @@ const parseStoryPage = async (linkPath, cache) => {
|
||||
.map((p) => $(p).text())
|
||||
.join('\n');
|
||||
}
|
||||
const imageLinks = $story
|
||||
.find('div > div > div > div > div > a')
|
||||
.toArray()
|
||||
.map((a) => $(a).attr('href'));
|
||||
const images = await Promise.all(imageLinks.map((imageLink) => parsePhotoPage(imageLink, cache)));
|
||||
|
||||
let images = [];
|
||||
if (isAttachAreImageSet) {
|
||||
images = await Promise.all(attachLinkList.map((link) => parsePhotoPage(link, cache)));
|
||||
}
|
||||
|
||||
return {
|
||||
url,
|
||||
|
||||
Reference in New Issue
Block a user