config = new ScraperConfiguration( new URL(configFilePath) );
} else {
config = new ScraperConfiguration(configFilePath);
}
Scraper scraper = new Scraper(config, workingDir);
String isDebug = (String) params.get("debug");
if ( CommonUtil.isBooleanTrue(isDebug) ) {
scraper.setDebug(true);
}
String proxyHost = (String) params.get("proxyhost");
if ( proxyHost != null && !"".equals(proxyHost)) {
String proxyPort = (String) params.get("proxyport");
if ( proxyPort != null && !"".equals(proxyPort) ) {
int port = Integer.parseInt(proxyPort);
scraper.getHttpClientManager().setHttpProxy(proxyHost, port);
} else {
scraper.getHttpClientManager().setHttpProxy(proxyHost);
}
}
String proxyUser = (String) params.get("proxyuser");
if ( proxyUser != null && !"".equals(proxyUser) ) {
String proxyPassword = (String) params.get("proxypassword");
String proxyNTHost = (String) params.get("proxynthost");
String proxyNTDomain = (String) params.get("proxyntdomain");
scraper.getHttpClientManager().setHttpProxyCredentials(proxyUser, proxyPassword, proxyNTHost, proxyNTDomain);
}
// adds initial variables to the scraper's content, if any
Map caseSensitiveParams = getArgValue(args, true);
Iterator iterator = caseSensitiveParams.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
String key = (String) entry.getKey();
if (key.startsWith("#")) {
String varName = key.substring(1);
if (varName.length() > 0) {
scraper.addVariableToContext(varName, entry.getValue());
}
}
}
scraper.execute();
}
}