我刚开始学习Ruby。 非常酷的语言,喜欢它了很多。
我使用的是非常方便的角度来说,Hpricot HTML解析器。
我所希望做的是抓住所有网页中的文本,但不包括HTML标记。
例:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Data Protection Checks</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div>
This is what I want to grab.
</div>
<p>
I also want to grab this text
</p>
</body>
</html>
我基本上想这样我结束了像这样的字符串抢只有文字:
“这是我想要抓住什么。我也想抓住这个文本”
什么是这样做的最佳方法是什么?
干杯
EEF