How to recreate an image preview from outside webs

2019-03-16 12:55发布

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!

2条回答
男人必须洒脱
2楼-- · 2019-03-16 13:36

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

查看更多
The star\"
3楼-- · 2019-03-16 13:37

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.

查看更多
登录 后发表回答