no such file to load -- mechanize
I did:
sudo gem install mechanize
and the following seems to be working:Shoes.setup do
gem 'mechanize'
end
require 'mechanize'
It says 'Building native extensions' and is taking forever, but seems to be the norm according to hackety.org. Rails rake mechanize - Error - No such file to load -- Mechanize
The task name is environment
, not enviroment
. There's a typo.
Change the line 2.
Ruby script cannot locate required gem
Gems must first be installed before you can require
them in a script. To install a gem; first open a terminal window and then type:
gem install GEM-NAME
or in your case: gem install mechanize
Error when trying to open a webpage with mechanize
You have to use a schema, otherwise mechanize thinks you are trying to open a local/relative path (as the error suggests).
br.open("google.com")
should be br.open("http://google.com")
.
Then you will see an error mechanize._response.httperror_seek_wrapper: HTTP Error 403: b'request disallowed by robots.txt'
, because google.com
does not allow crawlers. This can be remedied with br.set_handle_robots(False)
before open
.
Can't load 'mechanize' in rails 4.0.2
add this to Gemfile
gem 'mechanize'
then execute this command on the shell bundle
Related Topics
How to Send a Keep-Alive Packet Through Websocket in Ruby on Rails
Ruby/Active Record: Custom Sorting Order
How to Access a Toplevel Entity in Ruby, from Inside a Module Which Defines The Same Name
Using Elasticsearch to Filter Through Tags with Whitespace
How to Make Devise Registrationscontroller to Show Sign_Up Page Only If User Is Already Signed In
Shellwords.Shellescape Implementation for Ruby 1.8
Mongodb Server Doesn't Start at Gitlab Runner Using Gitlab-Ci
Puma and Nginx 502 Bad Gateway Error (Ubuntu Server 14.04)
Automatically Logging Exceptions in Ruby
In Ruby, How to Be Warned of Duplicate Keys in Hashes When Loading a Yaml Document
Rails Application Helper Didn't Support Chinese Characters
Access Rake Task Description from Within Task
Watir Changing Mozilla Firefox Preferences
Puzzled Over Palindromic Product Problem
Starting with Redmine Locally - How Easy Is Migration to Server Later