HTTParty不会加载Ruby文件

时间:2017-06-26 06:44:20

标签: ruby web-scraping httparty

我正在尝试运行webscraper,当我执行该文件时,我收到以下错误

/home/luis/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- httparty (LoadError)
    from /home/luis/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from luismejia71lbs.rb:1:in `<main>'

我安装了HTTParty,甚至运行了几次sudo gem install httparty以防万一。不知道为什么它不会运行,我找不到任何具体的东西。我最近在上周安装了rbenv,不确定是否相关,但是因为我过去能够运行httparty。

这是我的档案

webscraper.rb

require 'httparty'
require 'nokogiri'
require 'pry'
require 'json'
require 'csv'

craigslist = HTTParty.get('https://miami.craigslist.org/search/mdc/apa?min_bedrooms=3&max_bedrooms=3&min_bathrooms=2&max_bathrooms=2&availabilityMode=0')
Pry.start.(binding)

1 个答案:

答案 0 :(得分:2)

错误意味着rbenv无法找到httparty gem。由于rbenv在〜/ .rbenv下安装了gem,因此您不需要sudo命令来安装httparty。使用sudo几乎肯定会安装在错误的位置。只是做:

$ gem install httparty