Commit 28c271d5 by levphon

服务器端页面截图

1 parent 6600e0b0
...@@ -35,16 +35,17 @@ public class BrowserController { ...@@ -35,16 +35,17 @@ public class BrowserController {
@GetMapping("/screenshot") @GetMapping("/screenshot")
public R<String> screenshot(@RequestParam("url") String url, public R<String> screenshot(@RequestParam("url") String url,
String selector, String selector,
Integer timeout,
String filename, String filename,
Integer quality) throws IOException, InterruptedException { Integer quality) throws IOException, InterruptedException {
Page page = browser.newPage(); Page page = browser.newPage();
page.setDefaultTimeout(1000 * 6); page.setDefaultTimeout(timeout);
page.goTo(url, false); page.goTo(url, false);
//根据dom判断是否加载完 //根据dom判断是否加载完
WaitForSelectorOptions waitForSelectorOptions = new WaitForSelectorOptions(); WaitForSelectorOptions waitForSelectorOptions = new WaitForSelectorOptions();
waitForSelectorOptions.setTimeout(1000 * 6); waitForSelectorOptions.setTimeout(timeout);
waitForSelectorOptions.setVisible(Boolean.TRUE); waitForSelectorOptions.setVisible(Boolean.TRUE);
ElementHandle elementHandle = page.waitForSelector(StringUtils.isNotEmpty(selector) ? selector : "selector", waitForSelectorOptions); ElementHandle elementHandle = page.waitForSelector(StringUtils.isNotEmpty(selector) ? selector : "selector", waitForSelectorOptions);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!