I'm working on building a simple post miner using Ruby and the following tutorial (http://ngauthier.com/2014/06/scraping-the-web-with-ruby.html)
Here is my code I currently have:
#!/usr/bin/ruby
require 'capybara'
require 'capybara/poltergeist'
include Capybara::DSL
Capybara.default_driver = :poltergeist
visit "http://dilloncarter.com"
all(".posts .post ").each do |post|
title = post.find("h1 a").text
url = post.find("h1 a")["href"]
date = post.find("a")["datetime"]
summary = post.find("p.preview").text
puts title
puts url
puts date
puts summary
puts " "
end
and i'm getting errors loading the gemfiles like the following:
LoadError: cannot load such file -- capybara
from /Users/dilloncarter/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/dilloncarter/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from WP_Miner.rb:3
from /Users/dilloncarter/.rvm/rubies/ruby-2.0.0-p353/bin/irb:12:in `<main>'
How can I get my gems to load properly?
Have you installed capybara
and poltergeist
?
I just checked the tutorial you linked, and it doesn't seem to mention Gemfiles.
Also, if that is your script, you don't need a Gemfile.
All you need are the gems installed on your system and available in the ruby load path, and require
will find them.
Try in a terminal:
$ gem list capybara
To see if it's installed. If it isn't, install them both with:
$ gem install poltergeist
Capybara is a dependency of Poltergeist, and will be installed automatically.
Do that, and the script should work.
Add poltergeist to your Gemfile gem 'poltergeist'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With