在Centos6.3上安装Nokogiri

来源:互联网 发布:python 爬虫 抓取json 编辑:程序博客网 时间:2024/05/16 14:45

前提是已安装好Ruby(可以参照:Ruby安装 ),不然会安装失败,因为可能是缺少各种依赖包。

很多时候我们可能需要解析原始HTML。Ruby gem Nokogiri使读取原始HTML像crack-parsed XML and JSON一样容易。


gem install nokogiri

安装时遇到下面情况:

ERROR:  Could not find a valid gem 'nokogiri' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - Errno::ETIMEDOUT: 
Connection timed out - connect(2) for "s3.amazonaws.com" 
port 443 (https://api.rubygems.org/latest_specs.4.8.gz)

解决方法:

gem sources --remove https://rubygems.org/
gem sources -a https://ruby.taobao.org/
gem sources -l

因为解析完原始HTML,可以要入库,所以我安装了mysql驱动。


gem install mysql

如果出现包依赖问题,可以用下面命令试试:

yum -y install gcc mysql-devel ruby-devel rubygems libxml2 




0 0
原创粉丝点击