reddit not pulling scraping image on link post

谁说胖子不能爱 提交于 2019-12-24 09:17:01

问题


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. Use a squareish image, less than 1.5:1 ration on the sides.
  2. make the size as small as possible.
  3. link it with the open graph protocol http://ogp.me/

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" />

回答1:


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.

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.



来源:https://stackoverflow.com/questions/41478505/reddit-not-pulling-scraping-image-on-link-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!