PyCon is coming soon, watch for us!

January 27th, 2009 by comment gloriajw

I’ll be doing a tutorial on Kamaelia on Wednesday, March 25:

http://us.pycon.org/2009/tutorials/schedule/1AM7/

Alex McFerron is my assistant.

The fee which I would normally collect to teach this tutorial at PyCon (something like $750) will be donated to Alex’s Math Circle Outreach for kids.

All tutorials will be videotaped and put somewhere on the net. Exciting, eh? Watch for us. We’re going to rock this out.

If you’re at PyCon, feel free to say hi and take me out for a beer, to which I’ll gladly reciprocate. I’m staying for all of the tutorials and code sprints. Woot! I can’t wait!

My email addy: gloriajw_66 at yahoo dot com

Gloria

ˆ Back to top

Hpricot and woot!

January 13th, 2009 by comment Angel N. Sciortino

I know there are several sites for tracking wootoffs on Woot, but I wanted to write my own small program in Ruby. To do this, I used Hpricot by why the lucky stiff.

First, I need my require statements. I’ll need rubygems, since hpricot is a gem, and open-uri to access woot.

require 'rubygems'
require 'hpricot'
require 'open-uri'

Woot has an API that returns XML, so I used Hpricot::XML to parse what comes back.

doc = Hpricot::XML(open("http://www.woot.com/salerss.aspx"))

Now I want to know if it’s a wootoff. If it is, I’ll want to check more frequently. I use the at method to find the element I want, and inner_html to get the text inside that element. The element I’m interested in is woot:wootoff. I’m going to start putting the output into the text variable.

wootoff = doc.at("woot:wootoff").inner_html =~ /true/i
text = wootoff ? "wootoff! ^_^" : "no wootoff v_v"
text << "\n"

Next I want to know what the item is and the price and shipping.

text << doc.at("item > title").inner_html << "\n"
text << doc.at("woot:price").inner_html << " + "
text << doc.at("woot:shipping").inner_html << "\n"

I'll also want to know how much of the item is left, so I know if I need to rush to buy something I want.

percent_gone = doc.at("woot:soldoutpercentage").inner_html
percent_gone = percent_gone.to_f * 100
percent_left = (100 - percent_gone).round
text << "#{percent_left}% Left"

I took all that code and put it into a method, to be looped over every two minutes. I wanted it to print to the screen only if the text changed. This is what the completed program looks like.

#!/usr/bin/ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'

def woot_item
  doc = Hpricot::XML(open("http://www.woot.com/salerss.aspx"))
  wootoff = doc.at("woot:wootoff").inner_html =~ /true/i
  text = wootoff ? "wootoff! ^_^" : "no wootoff v_v"
  text << "\n"
  text << doc.at("item > title").inner_html << "\n"
  text << doc.at("woot:price").inner_html << " + "
  text << doc.at("woot:shipping").inner_html << "\n"
  percent_gone = doc.at("woot:soldoutpercentage").inner_html
  percent_gone = percent_gone.to_f * 100
  percent_left = (100 - percent_gone).round
  text << "#{percent_left}% Left"
end

woot_text = ''
while true
  new_woot_text = woot_item
  if woot_text != new_woot_text
    woot_text = new_woot_text
    puts "*****************************************************"
    puts woot_text
  end
  sleep 120
end

Here is some output from the program.

*****************************************************
no wootoff v_v
Lockjaw Self-Adjusting Locking Pliers - 2 Pack
$9.99 + $5 shipping
100% Left

Of course, this is only a beginning to what you can do. You can have it send a twitter, SMS, email, or any number of things if an item you want is available or a wootoff starts.

Angel

ˆ Back to top

She's Geeky

January 6th, 2009 by comment desi

Just wanted to remind everyone about the upcoming She’s Geeky Event in Mountain View CA Jan 30 – 31st. I already registered and got my flight booked so that I can be there. I hear from people who went last year and to the most recent one that the experience has been really good. So go check them out and get registered if you want to go.

Cheers
Desi

ˆ Back to top