Created
May 9, 2012 06:47
-
-
Save ywjno/2642513 to your computer and use it in GitHub Desktop.
login github used mechanize
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
# encoding: utf-8 | |
require 'rubygems' | |
require 'mechanize' | |
# Create a new mechanize object | |
agent = Mechanize.new | |
# set verify mode becaust the website used https | |
agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
# Load the github website | |
page = agent.get('http://github.com/login') | |
# Select the first form | |
form = page.forms[0] | |
# set your login and password in here | |
form.login = 'login' | |
form.password = 'password' | |
# Submit the form | |
page = form.submit form.buttons.first | |
# Print out the body | |
puts page.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment