Skip to content

Instantly share code, notes, and snippets.

@cduruk
Created November 11, 2008 19:16
Show Gist options
  • Save cduruk/23938 to your computer and use it in GitHub Desktop.
Save cduruk/23938 to your computer and use it in GitHub Desktop.
Small screen scraper to see if there have been updates in Turkish Guncem.com journal-keeping service.
# Tum haklari serbesttir.
require 'rubygems'
require 'mechanize'
require 'hpricot'
if ARGV.length < 2
puts "Kullanici adi ve sifre girmen lazim."
exit
end
agent = WWW::Mechanize.new { |agent|
agent.user_agent_alias = 'Mac Safari'
}
page = agent.get 'http://www.guncem.com'
form = page.forms.first
form['nick'] = ARGV[0]
form['pass'] = ARGV[1]
doc = form.click_button
result = Hpricot(doc.root.to_s)
if !((result/".f")[5].inner_html.strip).include? "Yorumunu"
puts "Yorumunu okumadigin gunceler var."
else
puts "Yorumunu okumadigin gunce yok."
end
if !((result/".f")[6].inner_html.strip).include? "yorum olan"
puts "Senden sonra yapilmis yorumlar var."
else
puts "Senden sonra yapilmis yorum yok."
end
if (result/".f")[7] != nil
puts "Okumadigin mesajlar var."
else
puts "Okumadigin mesaj yok."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment