Ruby 使用 Hpricot 进行 HTML 文档解析

2015-11-08 0 826
Ruby 使用 Hpricot 进行 HTML 文档解析
require 'hpricot'

html = <<END_OF_HTML
<html>
<head>
  <title>This is the page title</title>
</head>

<body>
  <h1>Big heading!</h1>
  <p>A paragraph of text.</p>
  <ul><li>Item 1 in a list</li><li>Item 2</li><li class="highlighted">Item
3</li></ul>
</body>
</html>
END_OF_HTML

doc = Hpricot(html)
puts doc.search("h1").first.inner_html

遇见资源网 ruby Ruby 使用 Hpricot 进行 HTML 文档解析 http://www.ox520.com/16545.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务