获取网页的打开图像? (当您共享其链接时,Facebook嵌入缩略图的方式)
- 假设对超级英雄的Wikipedia页面
在我的网页上,我想共享一个链接 对于该页面,Head标签中有以下代码:
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Connecticut_ComiCONN_Superhero_Mascot..jpg/640px-Connecticut_ComiCONN_Superhero_Mascot..jpg">
这是该页面的缩略图,如果您在社交媒体上共享链接,则显示。 (现在大多数页面都有一个)。
有没有办法检索嵌入我普通网页页面上的图像URL?
我正在使用CSS,HTML和JavaScript。
On my webpage I want to share a link - let's say to this wikipedia page for Superhero
In the code for that page there is the following code in the head tag:
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Connecticut_ComiCONN_Superhero_Mascot..jpg/640px-Connecticut_ComiCONN_Superhero_Mascot..jpg">
This is the thumbnail for that page that is shown if you share the link on social media. (Most pages now have one).
Is there a way to retrieve that image url to embed on my normal webpage page?
I'm using CSS, HTML and Javascript.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 https://www.opengraph.io/,例如:
https://opengraph.io/api/1.1/site/${url_encoded_link}?app_id=${your_api_key}
请注意,免费套餐每月仅允许 100 个请求。
另外,您也可以使用类似 open-graph-scraper - 从未尝试过,但看起来很有希望,据我所知,需要运行 NodeJS 服务器
。如果我理解正确的话, /package/parse-open-graph" rel="noreferrer">parse-open-graph 可以在浏览器中工作。
You can use https://www.opengraph.io/, for example:
https://opengraph.io/api/1.1/site/${url_encoded_link}?app_id=${your_api_key}
Note, that the free tier only allows 100 requests per month. And I'm not affiliated with it.
Alternatively, you can use something like open-graph-scraper - never tried, but looks promising, will require running NodeJS server as far as I understand.
This one parse-open-graph can work in browser, if I understand correctly.