|
44 | 44 | import org.slf4j.Logger; |
45 | 45 | import org.slf4j.LoggerFactory; |
46 | 46 | import java.net.*; |
| 47 | +import java.util.HashMap; |
47 | 48 | import java.util.List; |
48 | 49 | import java.util.Map; |
49 | 50 | import java.net.CookieHandler; |
@@ -220,14 +221,25 @@ public FetchedData fetch(Resource resource) throws Exception { |
220 | 221 | if (seleniumenabled.equals("true")) { |
221 | 222 | if(pluginConfig.get("chrome.selenium.script") != null && pluginConfig.get("chrome.selenium.script") instanceof Map) { |
222 | 223 | Map<String, Object> map = (Map<String, Object>) pluginConfig.get("chrome.selenium.script"); |
223 | | - scripter.runScript(map, null, null); |
| 224 | + try { |
| 225 | + scripter.runScript(map, null, null); |
| 226 | + } catch (Exception ignored){ |
| 227 | + |
| 228 | + } |
224 | 229 | List<String> snapshots = scripter.getSnapshots(); |
225 | 230 | html = String.join(",", snapshots); |
226 | 231 | } |
227 | 232 | } |
228 | 233 | if(json != null && json.containsKey("selenium")){ |
229 | 234 | if(json.get("selenium") != null && json.get("selenium") instanceof Map) { |
230 | | - scripter.runScript((Map<String, Object>) json.get("selenium"), null, null); |
| 235 | + try { |
| 236 | + scripter.runScript((Map<String, Object>) json.get("selenium"), null, null); |
| 237 | + } catch (Exception ignored){ |
| 238 | + Map<String, Object> tempmap = new HashMap<>(); |
| 239 | + tempmap.put("type", "file"); |
| 240 | + tempmap.put("targetdir", "/dbfs/FileStore/screenshots/"+resource.getCrawlId()+System.currentTimeMillis()); |
| 241 | + scripter.screenshot(tempmap); |
| 242 | + } |
231 | 243 | List<String> snapshots = scripter.getSnapshots(); |
232 | 244 | html = String.join(",", snapshots); |
233 | 245 | } |
|
0 commit comments