Skip to content

Instantly share code, notes, and snippets.

@timurvafin
Created November 26, 2008 13:42
Show Gist options
  • Save timurvafin/29389 to your computer and use it in GitHub Desktop.
Save timurvafin/29389 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
gem 'mechanize', '>= 0.8.5'
require 'mechanize'
if ARGV[0].nil? || ARGV[1].nil? || ARGV[2].nil?
raise ArgumentError
end
domain = ARGV[0]
login = ARGV[1]
password = ARGV[2]
a = WWW::Mechanize.new
a.get("http://#{domain}/wp-login.php") do |page|
# Submit the login form
my_page = page.form_with(:action => 'wp-login.php') do |f|
f.log = login
f.pwd = password
end.click_button
my_page.links.each do |link|
text = link.text.strip
next unless text.length > 0
puts text
end
end
http://mechanize.rubyforge.org/mechanize/
ruby login.rb tatsoft.ru login password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment