Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7089715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:57:22+00:00 2026-05-28T07:57:22+00:00

why do you need the full name for mechanize as so: #!/usr/bin/ruby -w require

  • 0

why do you need the full name for mechanize as so:

#!/usr/bin/ruby -w

require 'rubygems'
require 'pp'
require 'yaml'
require "mechanize"


yml = YAML.load_file 'login.yml'
user = yml["user"]
pword = yml["pword"]

a = WWW::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
end

when the mechanize example doesn’t do that? This is asked on top of a previous question. Code only worked after reading the previous question on this exact topic and adding the full class(?) name. I’ve seem somewhat similar in Java, but only when it’s ambiguous. Here, there’s nothing ambigious, there’s only the one Mechanize.

Pardon, the actual previous question completely contradicts the above link. The previous question I was referencing is here. To reiterate, two different questions, two different answers. Maybe the API or idiom changed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:57:23+00:00Added an answer on May 28, 2026 at 7:57 am

    What version of Mechanize are you using? Try gem list mechanize.

    Using Ruby 1.8.7-p357, 1.9.2-p290, and 1.9.3-p0 and Mechanize 2.1 I am able to instantiate an instance. For instance:

    1.8.7 :001 > require 'mechanize'
    true
    1.8.7 :002 > agent = Mechanize.new
    #<Mechanize:0x101baacf0
    [...]
    

    and:

    1.9.3p0 :001 > require 'mechanize'
    true
    1.9.3p0 :002 > agent = Mechanize.new
    #<Mechanize:0x102988610
    [...]
    

    I suspect you are using Mac OS, because you are accessing Ruby at /usr/bin. Ruby is not installed by default on Windows or Linux and wouldn’t be at that path normally.

    Apple’s version of Ruby doesn’t include Mechanize, so you added it at some point. Because Apple didn’t install it it should be benign to update, so do:

    sudo gem update mechanize
    

    Apple does use Ruby for apps on Mac OS, so you have to be aware of that when updating their pre-installed gems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to return a full directory name from inside a specified directory that
Have 2 table 1st {id_city,name } 2nd table {id_ctz,name,sname,age,id_city} need selected full information (name(city),name,sname,age)
I have a User class and store the user's submitted full name as a
I am trying to get FB user's full name using the access_token. I have
I need to convert full name to first and last name. Is this possible
I am trying to get the full name of a given user from active
Trying to figure out how to get the current User's Full Name as entered
I need to create a type from its full name only Ex: System.String or
I need the full client path of the file on the server side so
I need to add full web search to my site. I need something like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.