Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to recreate an image preview from outside websites?

Similar to Facebook's UI, I am attempting at generating a preview image from an external linked website. So that when a user types in a url he is linking, the UI will by default, scan that site for an img and scrape a preview thumb.

Is there a specific name for this technique? Or can anyone point me in the direction of learning this?

Thanks so much!

like image 700
Trip Avatar asked Jan 02 '11 15:01

Trip


2 Answers

Its called scraping. There is a library called scrAPI.

Here is a code example http://crunchlife.com/articles/2007/08/13/code-snippet-ruby-image-scraper

like image 130
ramn Avatar answered Sep 22 '22 18:09

ramn


There are a couple different options when it comes to page scraping. Another one to check out would be nokogiri, http://nokogiri.org/. You can find tutorials on how to use it at http://nokogiri.org/tutorials.

Instead of grabbing an image from the site, why not grab the image of the entire page? You could make use of a free screenshot service like http://www.websnapr.com/ or http://www.thumbshots.com/ among others. In one application, I use that for my preview image, and use nokogiri to scrape the page title and description. Just an idea.

like image 3
Glenn Avatar answered Sep 19 '22 18:09

Glenn