Skip to content

Instantly share code, notes, and snippets.

@linyiru
Created June 27, 2009 15:15
Show Gist options
  • Save linyiru/137022 to your computer and use it in GitHub Desktop.
Save linyiru/137022 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'hpricot'
def rip_twitpic(url)
begin
code=url.match(/[\w]+$/).to_s
unless code.blank?
uri=URI.parse(url)
resp=Net::HTTP.get_response(uri)
html=Hpricot(resp.body)
html.at("#photo-display")['src']
end
rescue Exception => e
puts "Error extracting twitpic: #{e}"
url
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment