Skip to content

Instantly share code, notes, and snippets.

@jccartwright
Created April 30, 2015 04:41
Show Gist options
  • Save jccartwright/2e5257d731c7d1ef2a8a to your computer and use it in GitHub Desktop.
Save jccartwright/2e5257d731c7d1ef2a8a to your computer and use it in GitHub Desktop.
parse a HTML file
def String getWmsUrl(url) {
def parser = new org.cyberneko.html.parsers.SAXParser()
parser.setFeature('http://xml.org/sax/features/namespaces', false)
def page = new XmlParser(parser).parse("${url}/MapServer?f=html")
def data = page.depthFirst().A.'@href'.grep{ it != null && it.endsWith('WMS') }
if (data) {
return data[0]
} else {
return null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment