centos上糾結nokogiri

來源:互聯網
上載者:User
# define the html url  url="http://mp3.baidu.com/"  # get the nokogiri document  doc = Nokogiri::HTML(open(url)) 

在centos上,上面這句話硬是解析不出來,試了N種寫法。

後來發現是nokogiri安裝的問題,如果用centos5.5,最新的libxml2的版本還是過低,centos就這樣,好用,穩定,但庫太老了點。

sudo yum remove -y libxml2 libxslt 

然後到這裡下載最新的libxml和libxslt安裝吧。

ftp://xmlsoft.org/libxml2/

gem install /home/xiao/.rvm/gems/ree-1.8.7-2011.03@rails3/cache/nokogiri-1.4.4.gem -- --with-xml2-lib=/opt/libxml2-dev/lib --with-xml2-include=/opt/libxml2-dev/include/libxml2 --with-xslt-lib=/opt/libxslt-dev/lib --with-xslt-include=/opt/libxslt-dev/include

再測試,一切ok.

這是我的資訊

[xiao@bogon collect]$ nokogiri -v
---
warnings: []

ruby:
engine: ruby
version: 1.8.7
platform: i686-linux
libxml:
loaded: 2.7.8
binding: extension
compiled: 2.7.8
nokogiri: 1.4.4

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.