Skip to content

Commit 3224a5b

Browse files
committed
add more stuff to chrome
1 parent 7ecffc2 commit 3224a5b

File tree

1 file changed

+14
-2
lines changed
  • sparkler-core/sparkler-plugins/fetcher-chrome/src/main/java/edu/usc/irds/sparkler/plugin

1 file changed

+14
-2
lines changed

sparkler-core/sparkler-plugins/fetcher-chrome/src/main/java/edu/usc/irds/sparkler/plugin/FetcherChrome.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.slf4j.Logger;
4545
import org.slf4j.LoggerFactory;
4646
import java.net.*;
47+
import java.util.HashMap;
4748
import java.util.List;
4849
import java.util.Map;
4950
import java.net.CookieHandler;
@@ -220,14 +221,25 @@ public FetchedData fetch(Resource resource) throws Exception {
220221
if (seleniumenabled.equals("true")) {
221222
if(pluginConfig.get("chrome.selenium.script") != null && pluginConfig.get("chrome.selenium.script") instanceof Map) {
222223
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+
}
224229
List<String> snapshots = scripter.getSnapshots();
225230
html = String.join(",", snapshots);
226231
}
227232
}
228233
if(json != null && json.containsKey("selenium")){
229234
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+
}
231243
List<String> snapshots = scripter.getSnapshots();
232244
html = String.join(",", snapshots);
233245
}

0 commit comments

Comments
 (0)