Skip to content

Instantly share code, notes, and snippets.

@pioz
Created December 14, 2011 11:18
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 pioz/1476188 to your computer and use it in GitHub Desktop.
Save pioz/1476188 to your computer and use it in GitHub Desktop.
Autovote on Monster WoW
require 'rubygems'
require 'mechanize'
require 'nokogiri'
agent = Mechanize.new
# Do login
page = agent.get('http://monster-wow.com/')
form = page.form_with(:name => 'login_form')
form.username = ARGV[0]
form.password = ARGV[1]
page = form.submit
# Exit if login fail
unless page.body.include?('You are now logged in!')
puts 'Login failed'
exit
end
# Get vote links and vote
page = agent.get('http://monster-wow.com/quest.php?name=votesites')
vote_links = page.links_with(:href => /^\.\/vote\.php\?vote=/)
vote_links.each do |link|
link.click
end
# Check current vote points
page = agent.get('http://monster-wow.com/')
doc = Nokogiri::HTML(page.body)
vote_points = doc.search('.mem-b-cont font')[2].content
puts "You have #{vote_points} vote points"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment