Sometimes it's good to be able to code :)
This ruby script checks the "when are we going to ship your laptop"; part of the Dell Homepage (Germany) for changes and notifies you via jabber when a change occured.
No exception handling —> if anything breaks, it's gone :P


require ‘rubygems'
require ‘open-uri'
require ‘hpricot'
require ‘xmpp4r'

#CONFIG
bestellnummer = "123456789";
kundennummer = "DE1234567";
bot_jabberid = "[email protected]";
bot_jabberpass = "secret_bot_password";
user_jabberid = "[email protected]";
#END OF CONFIG

myurl = "http://support.euro.dell.com/support/order/emea/OrderStatus.aspx?c=de&l=de&s=gen&on=#{bestellnummer}&cn=#{kundennummer}";
current_status = ""
while true

doc = Hpricot(open(myurl)) (doc/"a";).each do |a| if a.to_s.include?("order_status";) if current_status != a.inner_text puts "checking: NEW STATUS: " + a.inner_text client = Jabber::Client.new(Jabber::JID.new(bot_jabberid + "/dellbot";)) client.connect puts "jabber: connected"; client.auth(bot_jabberpass) puts "jabber: authenticated"; presence = Jabber::Presence.new presence.set_show(:chat) presence.set_status(‘notifying') presence.set_priority(-1) #we don't want to be top priority… the message might get to the bot client.send(presence) puts "jabber: set presence"; sleep 1 msg = Jabber::Message::new(user_jabberid, "Dell Status changed!\nNew Status: #{a.inner_text}";) msg.type=:chat client.send(msg) puts "jabber: sent message"; client.close! puts "jabber: disconnected";

ok, we sent that notification, so we can change our current status

current_status = a.inner_text else puts "checking: nothing new to see here, keep going!"; end end end sleep 600

end

Comments