Created
May 3, 2010 07:28
-
-
Save chanwit/387845 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import groovy.util.* | |
| import java.net.* | |
| class HomeController { | |
| def index = { | |
| // | |
| // read input via NekoHTML | |
| // | |
| def p = new XmlParser( new org.cyberneko.html.parsers.SAXParser() ) | |
| // | |
| // connect to InfoQ | |
| // then parse | |
| // | |
| def root = p.parse("http://infoq.com") | |
| // | |
| // next is to store output | |
| // | |
| def ba = new ByteArrayOutputStream() | |
| ba.withObjectOutputStream { out -> | |
| out << root | |
| } | |
| def bytes = ba.toByteArray() | |
| render "${bytes.size()}" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment