Skip to content

Commit

Permalink
Set page status code for SeleniumDownloader. Fixes #1185
Browse files Browse the repository at this point in the history
  • Loading branch information
sutra committed Dec 18, 2024
1 parent 9bb2417 commit b1cf7ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import us.codecraft.webmagic.Request;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.selector.PlainText;
import us.codecraft.webmagic.utils.HttpConstant;

import java.io.*;

Expand Down Expand Up @@ -96,7 +97,7 @@ public Page download(Request request, Task task) {
page.setRawText(content);
page.setUrl(new PlainText(request.getUrl()));
page.setRequest(request);
page.setStatusCode(200);
page.setStatusCode(HttpConstant.StatusCode.CODE_200);
}
onSuccess(page, task);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import us.codecraft.webmagic.downloader.AbstractDownloader;
import us.codecraft.webmagic.selector.Html;
import us.codecraft.webmagic.selector.PlainText;
import us.codecraft.webmagic.utils.HttpConstant;

import java.io.Closeable;
import java.io.IOException;
import java.net.http.HttpRequest;
import java.util.Map;

/**
Expand Down Expand Up @@ -111,6 +113,7 @@ public Page download(Request request, Task task) {
page.setHtml(new Html(content, request.getUrl()));
page.setUrl(new PlainText(request.getUrl()));
page.setRequest(request);
page.setStatusCode(HttpConstant.StatusCode.CODE_200);
onSuccess(page, task);
} catch (Exception e) {
logger.warn("download page {} error", request.getUrl(), e);
Expand Down

0 comments on commit b1cf7ae

Please sign in to comment.