|
|
|
@ -320,7 +320,7 @@ public class Spider implements Runnable, Task {
|
|
|
|
|
processRequest(request);
|
|
|
|
|
onSuccess(request);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
onError(request);
|
|
|
|
|
onError(request, e);
|
|
|
|
|
logger.error("process request " + request + " error", e);
|
|
|
|
|
} finally {
|
|
|
|
|
pageCount.incrementAndGet();
|
|
|
|
@ -338,10 +338,19 @@ public class Spider implements Runnable, Task {
|
|
|
|
|
logger.info("Spider {} closed! {} pages downloaded.", getUUID(), pageCount.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @deprecated Use {@link #onError(Request, Exception)} instead.
|
|
|
|
|
*/
|
|
|
|
|
@Deprecated
|
|
|
|
|
protected void onError(Request request) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void onError(Request request, Exception e) {
|
|
|
|
|
this.onError(request);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(spiderListeners)) {
|
|
|
|
|
for (SpiderListener spiderListener : spiderListeners) {
|
|
|
|
|
spiderListener.onError(request);
|
|
|
|
|
spiderListener.onError(request, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|