Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removing references to the WWW constant

  • Loading branch information...
commit d554726ee1da0adacf9103d921c7308bc983ed68 1 parent 8b8906b
@tenderlove tenderlove authored
View
18 EXAMPLES.rdoc
@@ -1,4 +1,4 @@
-= WWW::Mechanize examples
+= Mechanize examples
Note: Several examples show methods chained to the end of do/end blocks.
Do...end is the same as curly braces ({...}). For example, do ... end.submit
@@ -9,7 +9,7 @@ is the same as { ... }.submit.
require 'rubygems'
require 'mechanize'
- a = WWW::Mechanize.new { |agent|
+ a = Mechanize.new { |agent|
agent.user_agent_alias = 'Mac Safari'
}
@@ -28,7 +28,7 @@ is the same as { ... }.submit.
require 'rubygems'
require 'mechanize'
- a = WWW::Mechanize.new
+ a = Mechanize.new
a.get('http://rubyforge.org/') do |page|
# Click the login link
login_page = a.click(page.link_with(:text => /Log In/))
@@ -54,7 +54,7 @@ Upload a file to flickr.
abort "#{$0} login passwd filename" if (ARGV.size != 3)
- a = WWW::Mechanize.new { |agent|
+ a = Mechanize.new { |agent|
# Flickr refreshes after login
agent.follow_meta_refresh = true
}
@@ -87,7 +87,7 @@ This example shows you how:
require 'mechanize'
require 'rubyful_soup'
- class SoupParser < WWW::Mechanize::Page
+ class SoupParser < Mechanize::Page
attr_reader :soup
def initialize(uri = nil, response = nil, body = nil, code = nil)
@soup = BeautifulSoup.new(body)
@@ -95,7 +95,7 @@ This example shows you how:
end
end
- agent = WWW::Mechanize.new
+ agent = Mechanize.new
agent.pluggable_parser.html = SoupParser
Now all HTML pages will be parsed with the SoupParser class, and automatically
@@ -107,7 +107,7 @@ Beautiful Soup for that page.
require 'rubygems'
require 'mechanize'
- agent = WWW::Mechanize.new
+ agent = Mechanize.new
agent.set_proxy('localhost', '8000')
page = agent.get(ARGV[0])
puts page.body
@@ -124,7 +124,7 @@ This example also demonstrates subclassing Mechanize.
require 'rubygems'
require 'mechanize'
- class TestMech < WWW::Mechanize
+ class TestMech < Mechanize
def process
get 'http://rubyforge.org/'
search_form = page.forms.first
@@ -168,7 +168,7 @@ openssl.exe pkcs12 -in input_file.p12 -clcerts -out example.cer -nokeys
require 'mechanize'
# create Mechanize instance
- agent = WWW::Mechanize.new
+ agent = Mechanize.new
# set the path of the certificate file
agent.cert = 'example.cer'
View
10 GUIDE.rdoc
@@ -1,4 +1,4 @@
-= Getting Started With WWW::Mechanize
+= Getting Started With Mechanize
This guide is meant to get you started using Mechanize. By the end of this
guide, you should be able to fetch pages, click links, fill out and submit
forms, scrape data, and many other hopefully useful things. This guide
@@ -11,7 +11,7 @@ instantiate a new mechanize object:
require 'rubygems'
require 'mechanize'
- agent = WWW::Mechanize.new
+ agent = Mechanize.new
Now we'll use the agent we've created to fetch a page. Let's fetch google
with our mechanize agent:
page = agent.get('http://google.com/')
@@ -56,7 +56,7 @@ Lets continue with our google example. Here's the code we have so far:
require 'rubygems'
require 'mechanize'
- agent = WWW::Mechanize.new
+ agent = Mechanize.new
page = agent.get('http://google.com/')
If we pretty print the page, we can see that there is one form named 'f',
that has a couple buttons and a few fields:
@@ -69,7 +69,7 @@ object. So lets set the form field named 'q' on the form to 'ruby mechanize':
google_form.q = 'ruby mechanize'
To make sure that we set the value, lets pretty print the form, and you should
see a line similar to this:
- #<WWW::Mechanize::Field:0x1403488 @name="q", @value="ruby mechanize">
+ #<Mechanize::Field:0x1403488 @name="q", @value="ruby mechanize">
If you saw that the value of 'q' changed, you're on the right track! Now we
can submit the form and 'press' the submit button and print the results:
page = agent.submit(google_form, google_form.buttons.first)
@@ -83,7 +83,7 @@ Lets take a look at the code all together:
require 'rubygems'
require 'mechanize'
- agent = WWW::Mechanize.new
+ agent = Mechanize.new
page = agent.get('http://google.com/')
google_form = page.form('f')
google_form.q = 'ruby mechanize'
View
4 README.rdoc
@@ -1,6 +1,6 @@
-= WWW::Mechanize
+= Mechanize
-* http://mechanize.rubyforge.org/
+* http://mechanize.rubyforge.org
* http://github.com/tenderlove/mechanize/tree/master
== DESCRIPTION
View
2  examples/mech-dump.rb
@@ -3,5 +3,5 @@
require 'rubygems'
require 'mechanize'
-agent = WWW::Mechanize.new
+agent = Mechanize.new
puts agent.get(ARGV[0]).inspect
View
2  examples/proxy_req.rb
@@ -3,7 +3,7 @@
require 'rubygems'
require 'mechanize'
-agent = WWW::Mechanize.new
+agent = Mechanize.new
agent.set_proxy('localhost', '8000')
page = agent.get(ARGV[0])
puts page.body
View
2  examples/spider.rb
@@ -3,7 +3,7 @@
require 'rubygems'
require 'mechanize'
-agent = WWW::Mechanize.new
+agent = Mechanize.new
stack = agent.get(ARGV[0]).links
while l = stack.pop
next unless l.uri.host == agent.history.first.uri.host
View
4 lib/mechanize/form/file_upload.rb
@@ -1,8 +1,8 @@
class Mechanize
class Form
# This class represents a file upload field found in a form. To use this
- # class, set WWW::FileUpload#file_data= to the data of the file you want
- # to upload and WWW::FileUpload#mime_type= to the appropriate mime type
+ # class, set FileUpload#file_data= to the data of the file you want
+ # to upload and FileUpload#mime_type= to the appropriate mime type
# of the file.
# See the example in EXAMPLES[link://files/EXAMPLES_txt.html]
class FileUpload < Field
View
4 lib/mechanize/page.rb
@@ -98,11 +98,15 @@ def content_type
def_delegator :parser, :/, :/
def_delegator :parser, :at, :at
+ ##
+ # :method: form_with(criteria)
+ #
# Find a form matching +criteria+.
# Example:
# page.form_with(:action => '/post/login.php') do |f|
# ...
# end
+
[:form, :link, :base, :frame, :iframe].each do |type|
eval(<<-eomethod)
def #{type}s_with(criteria)
Please sign in to comment.
Something went wrong with that request. Please try again.