How to recreate an image preview from outside websites?

血红的双手。 提交于 2019-12-03 13:48:42

问题


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!


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/4579074/how-to-recreate-an-image-preview-from-outside-websites

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