Skip to content

Instantly share code, notes, and snippets.

@lyhcode
Created December 27, 2012 10:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyhcode/4387321 to your computer and use it in GitHub Desktop.
Save lyhcode/4387321 to your computer and use it in GitHub Desktop.
Groovy + NekoHTML simple demo
@Grab('net.sourceforge.nekohtml:nekohtml:1.9.16')
def parser = new org.cyberneko.html.parsers.SAXParser()
def page = new XmlParser(parser).parse('https://news.google.com/nwshp?hl=zh-TW&tab=wn')
page.depthFirst().DIV.grep{ it.'@class'=='title' }.each {
println it.A.SPAN.text()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment