Created
December 12, 2012 23:26
-
-
Save WA9ACE/4272651 to your computer and use it in GitHub Desktop.
Import domains to cpanel addon domains.
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 'mechanize' | |
require 'csv' | |
domains = %w{www.example.com} | |
# generates a password and associates it with a domain name then writes it to a CSV | |
puts 'Generating passwords...' | |
passwords = domains.map { ('0'..'z').select{|c| c =~ /\w/}.sample(10).join } | |
domain_pass_pair = domains.zip(passwords) | |
puts 'Writing domain password pairs to CSV...' | |
CSV.open("domains.csv", "wb") {|csv| domain_pass_pair.each {|elem| csv << elem} } | |
bot = Mechanize.new | |
user = '' | |
password = '' | |
url = '' | |
puts 'Logging in...' | |
page = bot.post url, [['user', user], ['pass', password]] | |
domain_pass_pair.each do |x| | |
domain = x[0] | |
password = x[1] | |
puts "Submitting #{domain} with password #{password}" | |
page = bot.get url | |
form = page.form_with(:id => 'mainform') | |
form.domain = domain | |
form.user = domain | |
form.dir = domain | |
form.pass = password | |
form.pass2 = password | |
form.submit | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment