Java: cdp4j - Java library for CDP,使用这个类库实现。
maven引入:
io.webfolder
cdp4j
1.1.0
官方例子:
import io.webfolder.cdp.Launcher;import io.webfolder.cdp.session.Session;import io.webfolder.cdp.session.SessionFactory;public class HelloWorld { public static void main(String[] args) { Launcher launcher = new Launcher(); try (SessionFactory factory = launcher.launch(); Session session = factory.create()) {
session.navigate("https://webfolder.io");
session.waitDocumentReady(); String content = (String) session.getProperty("//body", "outerText"); System.out.println(content);
}
}
}
更多例子,如PrintToPDF,请参考https://github.com/webfolderio/cdp4j