Ruby Code to Scrape Images from TwitPic URLs

Twitpic logo

I’ve been trying to find an easy way to re-grab my TwitPic images back off TwitPic to be re-syndicated on a communal family website I am trying to create.  I found a great site which had some Rails code that scraped the image, so I took the code and modified it to make it compatible for pure Ruby (too be honest it didn’t need much modifying at all) .

Here’s my modified snippet of code that I’ve been using to grab the image from Twitpic with the Hpricot gem:

require 'rubygems'
require 'net/http'
require 'hpricot'

def rip_twitpic(url)
  begin
    code=url.match(/[w]+$/).to_s
    unless code.empty?
      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

Just as it appears, this method will return the URL of the image embedded on the page that the TwitPic URL points too.

This will form the core part of a little project which will allow you to scrape TwitPic images and send them to a server of your choosing. I’ll try to release this ASAP but in the meantime, I thought a few of you might find this useful. I know I do.

It’s Just Too Noisy In Here

Until last night, I was following over 1100 people on Twitter. I love Twitter, but lately, I am feeling increasingly like every-time I open Twirl, I am being screamed at by 100 people at once.  It was becoming all nigh to follow what the people I really care about (@MrsAngell, @ChrisSaad, @michaelmcneill@DallasClark and @StephenKelly to name a few) where talking about.

Basically, as much as I’ve loved talking to you all, I just can’t keep it up.  In a society which is approaching economies of scarcity, I have reached a saturation point where my Twitter value is dropping because I can’t hold meaningful, deep, 140 character conversations with people anymore.  My Social Graph has become so wide that it barely holds definition anymore.  Too many trivial relationships, talking too loudly.

So starting last night, I’ve started a mass excommunication of my followers.   I have already culled over 300 people (thanks to Twitters recently improved interface tweaks).

Twitter _ People AshleyAngell is following

I am trying to be selective.  If you have *something* in common with me, professionally, personally, intellectually or geographically; then you’re probably safe.  I will an try to ensure that I follow people I converse with (so any @ replies count).

So, I am sorry if your one of the exiled, It’s not personal – It’s Just Too Noisy In Here!

Update

Twitter _ People AshleyAngell is following-1

TweetDeck

So on the advice of ReadWriteWeb, I downloaded and installed the new Twitter client, TweetDeck. On the surface I was very impressed, and if I had a dual screen setup it would be really good. It has some nifty little features, such as being able to group users into dedicated columns, and apart from allowing you to view your direct messages (sent and received) is pretty much what you would expect from an AIR-based Twitter application.

But there-in lies the problem; its really at heart, just another Twitter client. There is nothing outwardly special about it. No way to add rich media links to tweets and, frankly, nothing much that Snitter didn’t have months ago.

These days, with the plethora of Twitter applications out there, a Twitter app needs something special – and “edge” that TweetDeck simply doesn’t have (yet!). But if the founder(s) are smart, they’ll take on as much user advice as they can, and hopefully it will get there.

TweetDeck Screenshot

Update:
Ok, So it turns out that it DOES do DMs, but it puts them in the “replies” section, and while I can see why they did it, it wasn’t the behavior I expected.