使用 Ruby 解析 XHTML [英] Parse XHTML using Ruby

查看:23
本文介绍了使用 Ruby 解析 XHTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以在 Ruby 中解析远程 html 页面,最好使用 jQuery 之类的选择器?

Is there any way I can parse a remote html page, in Ruby, preferably using jQuery like selectors?

例如,我可以选择具有特定类的所有 div,并获取数组中所有这些元素的内容.

For example, I could select all the div having a specific class, and get the content of all those elements in an array.

为此我尝试使用 Regex,但我认为使用 XML 解析器会更好.

I was trying to use Regex for this, but I think using XML parser would be better.

推荐答案

我发现 hpricot 非常类似.

这篇关于使用 Ruby 解析 XHTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆