Skip to content

Commit

Permalink
Fix a typo in the examples.rdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
reddavis authored and tenderlove committed Dec 28, 2010
1 parent 533a32a commit 888b4e5
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions EXAMPLES.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ is the same as { ... }.submit.

require 'rubygems'
require 'mechanize'

a = Mechanize.new { |agent|
agent.user_agent_alias = 'Mac Safari'
}

a.get('http://google.com/') do |page|
search_result = page.form_with(:name => 'f') do |search|
search.q = 'Hello world'
end.submit

search_result.links.each do |link|
puts link.text
end
Expand All @@ -32,13 +32,13 @@ is the same as { ... }.submit.
a.get('http://rubyforge.org/') do |page|
# Click the login link
login_page = a.click(page.link_with(:text => /Log In/))

# Submit the login form
my_page = login_page.form_with(:action => '/account/login.php') do |f|
f.form_loginname = ARGV[0]
f.form_pw = ARGV[1]
end.click_button

my_page.links.each do |link|
text = link.text.strip
next unless text.length > 0
Expand All @@ -48,7 +48,7 @@ is the same as { ... }.submit.

== File Upload
Upload a file to flickr.

require 'rubygems'
require 'mechanize'

Expand Down Expand Up @@ -106,7 +106,7 @@ Beautiful Soup for that page.

require 'rubygems'
require 'mechanize'

agent = Mechanize.new
agent.set_proxy('localhost', '8000')
page = agent.get(ARGV[0])
Expand Down Expand Up @@ -155,8 +155,8 @@ This example also demonstrates subclassing Mechanize.

In most cases a client certificate is created as an additional layer of security
for certain websites. The specific case that this was initially tested on was
for automating the download of archived images from a banks (Wachovia) lockbox
system. Once the certificate is installed into your browser you will have to
for automating the download of archived images from a banks (Wachovia) lockbox
system. Once the certificate is installed into your browser you will have to
export it and split the certificate and private key into separate files. Exported
files are usually in .p12 format (IE 7 & Firefox 2.0) which stands for PKCS #12.
You can convert them from p12 to pem format by using the following commands:
Expand All @@ -169,17 +169,17 @@ openssl.exe pkcs12 -in input_file.p12 -clcerts -out example.cer -nokeys

# create Mechanize instance
agent = Mechanize.new

# set the path of the certificate file
agent.cert = 'example.cer'

# set the path of the private key file
agent.key = 'example.key'

# get the login form & fill it out with the username/password
login_form = @agent.get("http://example.com/login_page").form('Login')
login_form = agent.get("http://example.com/login_page").form('Login')
login_form.Userid = 'TestUser'
login_form.Password = 'TestPassword'

# submit login form
agent.submit(login_form, login_form.buttons.first)

0 comments on commit 888b4e5

Please sign in to comment.