LinkedIn URL 共享时预览不工作

LinkedIn URL preview not working while sharing

我创建了一个简单的 Node.js 网络服务器来在浏览器上呈现 html 内容。具体来说,html 包含用于在社交媒体上共享的元标记,以便在网站 link 在 FB、Twitter、LinkedIn 等社交平台上共享后立即启用 URL 预览

我已经在返回的 html 内容中添加了用于共享的开放图标签。它适用于 FB 和 Twitter,但会出现“我们在尝试检查 URL 时遇到服务器错误”的错误。作为回应。

这是带有虚拟端点的服务器代码。

const express=require('express');
const app = express();

require('dotenv').config();

app.get('/dummy',(req,res)=>{
    res.send(`
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Dummy Endpoint</title>
        <meta name="type" content="article" />
        <meta name="title" content="Dummy Endpoint"/>
        <meta name="description" content="Used for testing"/>
        <meta name="image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
        <meta property="og:type" content="article"/>
        <meta property="og:title" content="Dummy endpoint"/>
        <meta property="og:description" content="Used for testing"/>
        <meta property="og:image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
        <meta property="og:image:secure_url" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
        <meta property="og:image:secure" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
        <meta property="og:image:width" content="600" />
        <meta property="og:image:height" content="450" />
        <meta name="twitter:title" content="Dummy Endpoint"/>
        <meta name="twitter:description" content="Dummy endpoint"/>
        <meta name="twitter:image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
        <meta name="twitter:card" content="summary"/>
    `)
})

app.listen(process.env.PORT || 5000, () => {
    console.log('Server started at '+process.env.PORT)
});


网站link:https://whispering-woodland-66525.herokuapp.com/dummy(页面为空,检查Inspect中的head部分)

Facebook 共享调试器的响应:https://developers.facebook.com/tools/debug/?q=http%3A%2F%2Fwhispering-woodland-66525.herokuapp.com%2Fdummy

LinkedIn 的回复 Post 检查员:https://www.linkedin.com/post-inspector/inspect/https:%2F%2Fwhispering-woodland-66525.herokuapp.com%2Fdummy

我已经尝试多次刷新 Post Inspector 页面并向 Post Inspector 中的 url 添加一个虚拟查询参数以防止提供缓存内容,但是事情不顺利。

我无法理解代码中是否有错误或缺失,或者是 LinkedIn 网络爬虫的问题。

我相信 LinkedIn Post 检查员期待完整的 HTML 文档。考虑将您的元数据包装到文档的 header 中。尝试返回:

<!DOCTYPE html>
  <html lang="en">
    <head>
       <meta charset="UTF-8">
       <meta name="viewport" content="width=device-width, initial-scale=1.0">
       <title>Dummy Endpoint</title>
       <meta name="type" content="article" />
       <meta name="title" content="Dummy Endpoint"/>
       <meta name="description" content="Used for testing"/>
       <meta name="image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta property="og:type" content="article"/>
       <meta property="og:title" content="Dummy endpoint"/>
       <meta property="og:description" content="Used for testing"/>
       <meta property="og:image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta property="og:image:secure_url" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta property="og:image:secure" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta property="og:image:width" content="600" />
       <meta property="og:image:height" content="450" />
       <meta name="twitter:title" content="Dummy Endpoint"/>
       <meta name="twitter:description" content="Dummy endpoint"/>
       <meta name="twitter:image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta name="twitter:card" content="summary"/>
   </head>
</html>