Maven: <dependency> <groupId>org.ops4j.pax.carrot</groupId> <artifactId>pax-carrot-core</artifactId> <version>1.3.0</version> </dependency> Gradle: groovy dependencies { implementation 'org.ops4j.pax.carrot:pax-carrot-core:1.3.0' } import org.ops4j.pax.carrot.api.ExecutionContext; import org.ops4j.pax.carrot.api.Result; import org.ops4j.pax.carrot.parser.AbstractHtmlParser; public class HtmlParser extends AbstractHtmlParser { public HtmlParser(ExecutionContext executionContext) { super(executionContext); } @Override protected void doInitialize() { } @Override protected void doParse() { } @Override protected Result doVerify() { return null; } } import org.ops4j.pax.carrot.api.CarrotException; import org.ops4j.pax.carrot.api.ExecutionContext; import org.ops4j.pax.carrot.runner.CarrotRunner; public class App { public static void main(String[] args) { try { ExecutionContext executionContext = new ExecutionContext(); HtmlParser htmlParser = new HtmlParser(executionContext); CarrotRunner runner = new CarrotRunner(htmlParser); String html = "<html>...</html>"; runner.run(html); } catch (CarrotException e) { e.printStackTrace(); } } }


上一篇:
下一篇:
切换中文