Created
June 27, 2009 15:15
-
-
Save linyiru/137022 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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