java browser interface without the background screenshot tool

Disclaimer: Respect bloggers original articles, please indicate the source. If wrong, correct me hope. Contact: [email protected] https://blog.csdn.net/Supreme_Sir/article/details/89710069

Different from the previous article as mentioned by the client browser will HTMLturn canvasthe way again generated images, the contents of this record is a server-side ( Windows Server) screenshot tool. The tool is characterized by: By javano browser interface calling code .exefile, so no browser interface in the background HTMLrendering and screenshots, screenshots and save to the specified path. code show as below:

ScreenshotDemo.java

import java.io.File;
import java.io.IOException;

public class ScreenshotDemo{
 
 	// 工具所在根目录
	private static String root = "E:\\cut\\截图工具";
	private static String jsPath = root + File.separator + "screenshot.js ";
	private static String exePath = root + File.separator + "phantomjs.exe";
 

 
	// 调用phantomjs程序,并传入js文件,并通过流拿回需要的数据。
	public static void getParseredHtml2(String url,String path) throws IOException{
		Runtime rt = Runtime.getRuntime();
		Process p = rt.exec(exePath + " " + jsPath + " " + url+" "+path);
		  
	}
	
	// 执行测试
	public static void main(String[] args) throws IOException {
		getParseredHtml2("http://www.baidu.com","E:/Baidu.png");
	}
 
}  

FIG file path as follows:

Here Insert Picture Description
PS:

  1. If I have written to intercept HTMLfile, make sure the file is no ECMAScript 6(简称ES6)grammar, because the screenshot tool does not! support! hold! ! !
  2. Sample code and tools CSDN download link: https://download.csdn.net/download/supreme_sir/11149969
  3. No Download Credits may leave the mailbox or send mail into the mailbox at the top of this article copyright notice in the comments area, Bo Lord replies in the first time after seeing.

OJBK!

I declare: Now from work!

Guess you like

Origin blog.csdn.net/Supreme_Sir/article/details/89710069