大型网站如何从链接中捕获缩略图? [英] How major websites capture thumbnails from a link?

查看:173
本文介绍了大型网站如何从链接中捕获缩略图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Digg和Facebook等主要网站上分享链接时;它将通过捕获页面的主要图像创建缩略图。他们如何从网页抓取图片?是否包括加载整个页面(例如通过cURL)和解析它(例如与preg_match)?对我来说,这种方法是缓慢和不可靠的。他们有更实用的方法吗?

When sharing a link in major websites like Digg and Facebook; it will create thumbnails by capturing main images of the page. How they catch images from a webpage? Does it included loading the whole page (e.g. by cURL) and parsing it (e.g. with preg_match) ? To me, this method is slow and unreliable. Does they have a more practical method?

我认为应该有一个实用的方法,通过跳过一些部分(例如CSS和JS)到达src属性快速抓取页面。任何想法?

P.S. I think there should be a practical method for quick crawling the page by skipping some parts (e.g. CSS and JS) to reach src attributes. Any idea?

推荐答案

他们通常在网页上寻找图片,并在服务器上扩展。 Reddit的刮板代码显示了大量的他们是这样。 Scraper课程应该为您提供一些关于如何解决这个问题的好主意。

They typcailly look for an image on the page, and scale it down on their servers. Reddit's scraper code shows a good deal of what they do. The Scraper class should give you some good ideas on how to tackle this.

这篇关于大型网站如何从链接中捕获缩略图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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