Facebook/Twitter OpenGraph 不在 Node.js/Angular.js Web 应用程序上抓取图像

Facebook/Twitter OpenGraph not scraping images on Node.js/Angular.js web application

我最近在开发一个 MEAN Stack 应用程序,在某种程度上是一种博客,其中作者 post 文章。为了克服 OpenGraph 应用程序不抓取 Javascript 的问题,我在我的 Nginx 反向代理上实施了一个静态 php 页面和一个规则,该规则重定向来自某些用户代理(如 Facebook,Google+、Twitter 等)到静态页面,以便正确抓取数据。

一切都很好,除了一个小细节,基于 OpenGraph 的应用程序似乎无法抓取文章中的图像,因此丰富的社交分享没有达到预期效果。

例如,测试以下 link : https://moveramontanha.pt/article/5a21539cfdebb1074ed1436d

重定向到静态页面:

https://www.moveramontanha.pt/static_mam.php?id=5a21539cfdebb1074ed1436d

Unsupported Image File Extension Provided og:image URL, https://www.moveramontanha.pt/uploads/authors/1512141975423.jpg does not have a supported extension.

The provided 'og:image' properties are not yet available because new images are processed asynchronously. To ensure shares of new URLs include an image, specify the dimensions using 'og:image:width' and 'og:image:height' tags.

INFO: Page fetched successfully INFO: 17 metatags were found INFO: twitter:card = summary tag found INFO: Card loaded successfully WARN: this card is redirected to https://www.moveramontanha.pt/static_mam.php?id=5a21539cfdebb1074ed1436d

我已经尝试添加额外的标签,例如图像 width/height、更改图像格式、安全标签等。没有任何效果。

还有其他人遇到过这样的问题吗?

提前致谢!

对于 Twitter 的卡片爬虫,有一个深入的故障排除常见问题解答 here and here

我刚刚尝试了以下请求来获取页面中引用的图像:

curl -L -A Twitterbot -v https://www.moveramontanha.pt/uploads/authors/1501255270817.jpg

这 return 是一个 HTML 页面,不是 JPEG 图片。这意味着 Twitter 的卡片爬虫无法获取有效图像。

您应该将您的服务器修复为 return 向 Twitterbot 用户代理发送有效的 JPEG 图片。