Seeking resources to help do external image preview (scraping) like FB and subsequent full-size image capture
seeking resources or guidance to help generate an image preview from a link, similar to the one used in Facebook's UI, and then subsequently also allow a user to display / grab the full size image of the preview as well. Not l开发者_StackOverflow社区ooking to necessarily create a bookmarklet a la svpply.com or the like, but interested in figuring out a way whereby a user can enter a link, select the image they want on the page they've linked to, and then have that image (in full, or near to full-size) added to a post or submission to a web page.
Any help, guidance, or anything would be greatly appreciated!!
Thank you!
This might not be a perfect solution, but I am using it at the moment to populate a database entry with some info fetched from an external URL. This is just to fetch the contents, without taking the image (still working on it). I use Nokogiri gem to HTML
class Link < ActiveRecord::Base
require 'open-uri'  
....    
def fill_from_url(url_input)
  url_input = url_input.strip
  self.url = url_input    
  self.valid?
  existing_link = Link.find_by_url(url_input)
  if self.errors.messages.has_key?(:url)            
    return self.errors.messages
  else      
    page = open(url_input)
    target_url = page.base_uri.to_s
    input = Nokogiri::HTML.parse(page)
    desc = input.at('head/meta[@name="description"]/@content')
    kws = input.at('head/meta[@name="keywords"]/@content')
    lang = input.at('html/@lang')
    if input.at('head/title')
      self.title = input.at('head/title').content.gsub("\n"||"\r"||"\t",'').squeeze(" ").strip
    else
      self.title = input.at('title').content.gsub("\n"||"\r"||"\t",'').squeeze(" ").strip    
    end
    self.url = target_url.to_s            
    self.website = target_url.split('/')[2]                  
    self.description = desc.content[0..2000] if desc            
    self.keywords = kws.content[0..2000] if kws      
    self.language_code = lang.content if lang
  end
end
...
end
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论