<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>michaelschobert &#187; scripts</title>
	<atom:link href="http://www.michaelschobert.net/category/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michaelschobert.net</link>
	<description>This and That - Homepage &#38; Blog of Michael Schobert</description>
	<lastBuildDate>Sat, 26 Jun 2010 14:38:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>APress Deal of the day</title>
		<link>http://www.michaelschobert.net/2008/03/29/apress-deal-of-the-day/</link>
		<comments>http://www.michaelschobert.net/2008/03/29/apress-deal-of-the-day/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 19:34:45 +0000</pubDate>
		<dc:creator>Michael Schobert</dc:creator>
				<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://michaelschobert.net/?p=25</guid>
		<description><![CDATA[I recently stumbled upon a nice deal on the APress website. They offer a different title as electronic book for $ 10 each day (called ebook deal of the day). After a couple of days I started to be annoyed &#8230; <a href="http://www.michaelschobert.net/2008/03/29/apress-deal-of-the-day/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently stumbled upon a nice deal on the <a href="http://www.apress.com/">APress</a> website. They offer a different title as electronic book for $ 10 each day (called <a href="http://www.apress.com/info/dailydeal">ebook deal of the day</a>).</p>
<p>After a couple of days I started to be annoyed by looking on the website every day and wondered how I can make sure that I do not miss something interesting.</p>
<p>I went on and wrote a little ruby script with the cool hpricot library by why the lucky stiff. It runs as a cron job every day and sends an email with the title and description.</p>
<p>In case you are interested, here it is (just edit the smtp_server, sender and receiver variables):</p>
<pre>#!/usr/bin/env ruby

require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'net/smtp'

smtp_server = 'your_mail_server'
sender = "your@email_address.here"
receiver = ['receiver1@test.xx', 'receiver2@test.xx']

doc = Hpricot(open("http://www.apress.com/info/dailydeal"))

description = doc.search("//div[@class='bookdetails']")

title = description.search("a").first.inner_html

msg = "Subject: [APress Deal of the Day] #{title}\n\nDeal of the day at APress: #{title}\n\n"

(description/"p").each do |p|
        msg = msg + p.inner_html.gsub(/&lt;\/?[^&gt;]*&gt;/, "") + "\n\n"
end

msg = msg + (description/"div[@class='footer']").inner_html + "\n\n"

msg = msg + "Order at http://www.apress.com/info/dailydeal\n"

Net::SMTP.start(smtp_server) do |smtp|
        smtp.send_message(msg, sender, receiver)
end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelschobert.net/2008/03/29/apress-deal-of-the-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
