reddit不拉链接页面上的抓取图像 [英] reddit not pulling scraping image on link post

查看:155
本文介绍了reddit不拉链接页面上的抓取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在链接帖子上,reddit刮板未从我的站点刮取图像以获取缩略图,并且我看不到原因.我遵循了我能找到的所有基本内容的小片段.

On link posts, the reddit scraper is not scraping an image from my site for a thumbnail and I cannot see why. I have followed any small snippet I could find about it which basically said.

  1. 使用方形图像,侧面的比例小于1.5:1.
  2. 使尺寸尽可能小.
  3. 将其与开放图谱协议链接 http://ogp.me/

我已经完成了所有这些操作,并将其添加到html中,但是没有运气,也无处可寻.

I have done all of these and added this in the html with no luck, and nowhere else to turn to.

<meta property="og:image:secure_url" content="static/screenshot.png" />

推荐答案

如果抓取代码直接传递给_fetch_url() ,其中调用_initialize_request() ,其中忽略非绝对网址.因此,请尝试为您的图片指定一个绝对网址,它应该可以正常工作.

If the scraping code finds an og:image, it will return the url unmodified. This url is then passed directly to _fetch_url(), which calls _initialize_request(), which ignores non-absolute urls. So, try specifying an absolute url for your image and it should work.

从Open Graph规范的简要介绍中,我看不到任何需要绝对URL的信息,因此这可能被视为reddit中的错误.解决该问题相当容易,因为相关代码已经可以访问请求的页面以设置引荐来源,因此您不妨在r/bug上发布它.

From a brief look at the Open Graph spec, I don't see anything about requiring absolute urls, so this might be considered a bug in reddit. It would be fairly easy to solve, since the relevant code already has access to the requested page for the purposes of setting the referrer, so you may wish to post about it on r/bugs.

这篇关于reddit不拉链接页面上的抓取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆