I want to play around with NekoHtml, in Groovy. I thought of adding it via Grape.
I tried this way :
@GrabResolver(root="http://net.sourceforge.nekohtml/nekohtml")
in my Groovy code.
But it is throwing an error like this :
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/home/anto/Groovy/webScrape/webFetch.groovy: 3: unexpected token: @ line 3, column 1.
The NekoHtml can be found in Maven over here.
Now I have a code like this :
@Grab('net.sourceforge.nekohtml:nekohtml:1.9.15')
import org.cyberneko.html.parsers.SAXParser
def url = 'http://java.sun.com'
def html = new XmlSlurper(new org.cyberneko.html.parsers.SAXParser()).parse(url)
def bolded = html.'**'.findAll{ it.name() == 'B' }
def out = bolded.A*.text().collect{ it.trim() }
out.removeAll([''])
out[2..5].each{ println it }
which throws the error like this :
Caught: java.lang.NoClassDefFoundError: org/apache/xerces/parsers/AbstractSAXParser
java.lang.NoClassDefFoundError: org/apache/xerces/parsers/AbstractSAXParser
Caused by: java.lang.ClassNotFoundException: org.apache.xerces.parsers.AbstractSAXParser
Couldn't able to figure out what this error states.
Thanks in advance.
Have you tried:
@Grab('net.sourceforge.nekohtml:nekohtml:1.9.15')
Then it should resolve from maven