Home 一个例子,ruby解析html页面.(nokogiri,httparty,ruby)
Post
Cancel

一个例子,ruby解析html页面.(nokogiri,httparty,ruby)

有些网页需要我们获取信息

require 'httparty'
require 'nokogiri'

url ='https://github.com/rdoc/rdoc/issues/190'
response = HTTParty.get  url 
puts response.body
doc = Nokogiri::HTML response.body
doc.css('.js-issue-title').each do  |node|
  puts node.content
end

保存下来后,   
$ gem install httparty

$ gem install nokogiri

就可以直接运行   

This post is licensed under CC BY 4.0 by the author.