Skip to content

Instantly share code, notes, and snippets.

@hank
Created August 24, 2009 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hank/173623 to your computer and use it in GitHub Desktop.
Save hank/173623 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'open-uri'
require 'hpricot'
require 'rss/maker'
version = "2.0"
destination = ENV['HOME']+"/public_html/md_super_ads.xml"
content = RSS::Maker.make(version) do |m|
m.channel.title = "MD Super Ads Classifieds RSS"
m.channel.link = "http://www.ralree.info/md_super_ads.xml"
m.channel.description = "MD Super ads has good deals!"
m.items.do_sort = true
doc = Hpricot(open('http://www.marylandsuperads.com/items_for_sale_Classifieds/index.aspx').read)
(doc/'div[@class=item]').each do |item|
# For every anchor that isn't an image...
i = m.items.new_item
i.title = (item/'span[@class=itemTitle]/a').inner_html
i.link = "http://www.marylandsuperads.com"+(item/'span[@class=itemTitle]/a')[-1]['href']
i.date = Time.parse(((item/'div[@class=description]/table/tr/td')[-1]/'div').inner_html.gsub(/.* (.*)/, '\1').strip+" 12:00")
i.description = (item/'div[@class=description]').inner_html
end
end
File.open(destination, "w") do |f|
f.write(content)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment