如何使用clojure解析html文件? [英] How to parse html file using clojure?
本文介绍了如何使用clojure解析html文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是clojure的新手,需要一些例子。请告诉我如何使用clojure解析html文件? Enlive / a>是一个很好的工具。总之:
(ns foo.bar
(:require [net.cgrand.enlive-html:as html ]))
(defn fetch-page [url]
(html / html-resource(java.net.URL。url)))
此处是一个很好的教程,它将它用作刮板/解析器和模板引擎:
这里是一个简单的抓取页面的例子。
另一个选项是 clj-tagsoup 。 Enlive还使用了tagsoup,但另外还有一个可插入的解析器,因此您可以添加对其他解析器的支持。
I'm new to clojure and I need some examples. Please show me how to parse html file using clojure?
解决方案
Enlive is a great tool for this. In short:
(ns foo.bar
(:require [net.cgrand.enlive-html :as html]))
(defn fetch-page [url]
(html/html-resource (java.net.URL. url)))
Here is a nice tutorial on using it both as a scraper/parser and as a template engine:
Here is a short example of scraping a page.
Another option is clj-tagsoup. Enlive also uses tagsoup, but in addition has a pluggable parser so you can add support for other parsers.
这篇关于如何使用clojure解析html文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文