4. Nokogiri (鋸) is an HTML, XML, SAX, and Reader
parser. Among Nokogiri's many features is the
ability to search documents via XPath or CSS3
selectors. XML is like violence - if it doesn’t solve
your problems, you are not using enough of it.
5. Nokogiri 는 HTML, XML 파서 입니다.
Nokogiri는 XPath 또는 CSS3 셀렉터를 이용해
문서를 탐색하는 기능이 있습니다.
6. sudo apt-get install zlib1g-dev
sudo gem install nokogiri
설치(on ubuntu)
Other OS : http://www.nokogiri.org/tutorials/
installing_nokogiri.html
9. 예제
require ‘nokogiri’
html_doc = Nokogiri::HTML(“<html><body><table border=1><tr><td>월</td><td>
화</td><td>수</td></tr><tr><td>야근</td><td>칼퇴</td><td>조퇴</td></tr></
table></body></html>”)
result = html_doc.xpath(‘//html/body/table/tr/td') // 이렇게 xpath를 이용해 접근
puts result[4].content //html 코드중 4번째 td태그의 값을 출력함
10. nokogiri는 웹 크롤링 할때 편하다
ruby 프로젝트에서 웹크롤링을 해서 DB에 값을 저장할때 쓰면 편함
url을 파싱할수도 있고, xml도 파싱 가능함