Created
December 14, 2011 11:18
-
-
Save pioz/1476188 to your computer and use it in GitHub Desktop.
Autovote on Monster WoW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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