Ruby的HTML/XML解析库 Nokogiri

码农软件 · 软件分类 · HTML解析器 · 2019-04-03 16:27:29

软件介绍

Aaron Patterson和Mike Dalessio开发了一个新的Ruby解析HTML/XML的ruby库 - Nokogiri。他的速度比目前应用的最广泛的Hpricot还要快许多。经过Benchmark测试表明,Nokogiri在加载XML文档的速度是Hpricot的7倍,在XPATH搜索的速度是Hpricot的5倍,而在CSS选择器的搜索上面是Hpricot的1.62倍。

因此Nokogiri被认为有可能取代Hpricot的新一代Ruby的解析库,他能够解析HTML/XML文件,能够提供XPATH支持,CSS选择器支持。安装Nokogiri的办法很简单: gem install nokogiri 

示例代码:

 

require 'nokogiri'

html = '...'
doc = Nokogiri::HTML(html)

# 获取页面上所有的链接
doc.css('a').each do |link|
  puts "#{link.content}, #{link['href']}"
end

# 打出 meta-keywords
puts doc.css('meta[name="keywords"'])[0].content

本文地址:https://codercto.com/soft/d/2781.html

APIs

APIs

Daniel Jacobson、Greg Brail、Dan Woods / O'Reilly Media / 2011-12-24 / USD 24.99

Many of the highest traffic sites get more than half of their traffic not through the browser but through the APIs they have created. Salesforce.com (more than 50%) and Twitter (more than 75% fall int......一起来看看 《APIs》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

随机密码生成器
随机密码生成器

多种字符组合密码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码