nokogiri

Mac user and getting WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded 2.7.3

只愿长相守 提交于 2019-12-17 04:48:05
问题 I have done all kinds of research and tried many different things. I know this question has been answered many times, but none of the suggested solutions are working for me. After upgrading to Lion I am getting segmentation faults in Ruby. I'm fairly confident it's Nokogiri. So I installed libxml2 via Homebrew. I ran brew link libxml2 . Then I reinstalled Nokogiri using that version of the library. For proof: $ nokogiri -v # Nokogiri (1.5.0) --- warnings: [] nokogiri: 1.5.0 ruby: version: 1.9

Mac user and getting WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded 2.7.3

泪湿孤枕 提交于 2019-12-17 04:46:10
问题 I have done all kinds of research and tried many different things. I know this question has been answered many times, but none of the suggested solutions are working for me. After upgrading to Lion I am getting segmentation faults in Ruby. I'm fairly confident it's Nokogiri. So I installed libxml2 via Homebrew. I ran brew link libxml2 . Then I reinstalled Nokogiri using that version of the library. For proof: $ nokogiri -v # Nokogiri (1.5.0) --- warnings: [] nokogiri: 1.5.0 ruby: version: 1.9

Why does installing Nokogiri on Mac OS fail with libiconv is missing?

吃可爱长大的小学妹 提交于 2019-12-17 02:40:09
问题 I've been trying to install Nokogiri on Mac OS 10.9.3 and whatever I try, the install fails in the end with the following error message: $ sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib Building native extensions with: '--with-xml2

How to avoid joining all text from Nodes when scraping

橙三吉。 提交于 2019-12-16 20:06:38
问题 When I scrape several related nodes from HTML or XML to extract the text, all the text is joined into one long string, making it impossible to recover the individual text strings. For instance: require 'nokogiri' doc = Nokogiri::HTML(<<EOT) <html> <body> <p>foo</p> <p>bar</p> <p>baz</p> </body> </html> EOT doc.search('p').text # => "foobarbaz" But what I want is: ["foo", "bar", "baz"] The same happens when scraping XML: doc = Nokogiri::XML(<<EOT) <root> <block> <entries>foo</entries> <entries

How to avoid joining all text from Nodes when scraping

↘锁芯ラ 提交于 2019-12-16 20:05:46
问题 When I scrape several related nodes from HTML or XML to extract the text, all the text is joined into one long string, making it impossible to recover the individual text strings. For instance: require 'nokogiri' doc = Nokogiri::HTML(<<EOT) <html> <body> <p>foo</p> <p>bar</p> <p>baz</p> </body> </html> EOT doc.search('p').text # => "foobarbaz" But what I want is: ["foo", "bar", "baz"] The same happens when scraping XML: doc = Nokogiri::XML(<<EOT) <root> <block> <entries>foo</entries> <entries

Ruby 2 Upgrade Breaks Nokogiri and/or open-uri Encoding?

风流意气都作罢 提交于 2019-12-14 04:17:09
问题 I have a mystery to solve when upgrading our Rails3.2 Ruby 1.9 app to a Rails3.2 Ruby 2.1.2 one. Nokogiri seems to break, in that it changes its behavior using open-uri. No gem versions are changed, just the ruby version (this is all on OSX Mavericks, using brew, gcc4 etc). Steps to reproduce: $ ruby -v ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-darwin13.1.0] $ rails console Connecting to database specified by database.yml Loading development environment (Rails 3.2.18) > feed =

refactoring Ruby scraping code

北城以北 提交于 2019-12-14 04:01:17
问题 Basically, I will have multiple .main_entry blocks on each page and I will need to pull a couple of pieces of data from each. How can this be properly refactored into methods? require 'open-uri' require 'nokogiri' url = #url doc = Nokogiri::HTML(open(url)) doc.css(".main_entry").each do |item| artist = item.at_css(".list_artist").text title = item.at_css(".list_album").text puts "#{artist} - #{title}" end I have arrived at this mess below, which throws the undefined local variable or method

Extracting multiple-line content under header tags

六眼飞鱼酱① 提交于 2019-12-14 02:36:13
问题 I posted a similar question that did not take into account multiple lines in the body. I have an html like so that I want to extract the "bodies" of (using Nokogiri): html = %q| <div class="content"> <h1>Title 1</h1> Lorem ipsum 1 <h2>Title 2</h2> Lorem ipsum 2 <h3>Title 3</h3> <p>paragraph content 1</p> <b>Lorem ipsum 3</b> <p>paragraph content 2</p> <h1>Title 4</h1> Lorem ipsum 4 <h2>Title 5</h2> Lorem ipsum 5 </div> | I want to extract the body content under each header title and place

rails.strip_tags for html with carriage return

試著忘記壹切 提交于 2019-12-14 02:17:11
问题 Following code converts \r to is it correct? strip_tags "<a>aaa</b>\r\n<!-- aaa -->" # => "aaa \n" is it correct? I supposed to receive "aaa\r\n" 回答1: I've encountered the same issue recently. I've tested on both rails 4.0.12 and 4.2.0, and only saw aaa&#13\n on 4.2.0. So I guess it might be an issue in the later version. 回答2: fixed there: https://github.com/rails/rails-html-sanitizer/issues/31 The reason is related to encoding special characters. Some related bugs are fixed in Rails 4.2.1

How to install Nokogiri Ruby gem with mkmf.log saying libiconv not found?

我们两清 提交于 2019-12-14 00:15:56
问题 I'm installing the Ruby Nokogiri gem and finding the error below. How to diagnose this and solve it? # gem install nokogiri Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. ... /opt/ruby/1.9.3-p194/bin/ruby extconf.rb checking for libxml/parser.h... *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more