修复HDU,POJ题目图片显示问题

This commit is contained in:
Himit_ZH 2021-08-04 22:17:55 +08:00
parent 8dab12a089
commit bd19622380
2 changed files with 5 additions and 4 deletions

View File

@ -27,7 +27,7 @@ public class HDUProblemStrategy extends ProblemStrategy {
@Override @Override
public RemoteProblemInfo getProblemInfo(String problemId, String author) throws Exception { public RemoteProblemInfo getProblemInfo(String problemId, String author) throws Exception {
// 验证题号是否符合规范 // 验证题号是否符合规范
Assert.isTrue(problemId.matches("[1-9]\\d*"),"HDU题号格式错误"); Assert.isTrue(problemId.matches("[1-9]\\d*"), "HDU题号格式错误");
Problem info = new Problem(); Problem info = new Problem();
String url = HOST + String.format(PROBLEM_URL, problemId); String url = HOST + String.format(PROBLEM_URL, problemId);
Connection connection = JsoupUtils.getConnectionFromUrl(url, null, null); Connection connection = JsoupUtils.getConnectionFromUrl(url, null, null);
@ -37,7 +37,8 @@ public class HDUProblemStrategy extends ProblemStrategy {
info.setTitle(ReUtil.get("color:#1A5CC8\">([\\s\\S]*?)</h1>", html, 1).trim()); info.setTitle(ReUtil.get("color:#1A5CC8\">([\\s\\S]*?)</h1>", html, 1).trim());
info.setTimeLimit(Integer.parseInt(ReUtil.get("(\\d*) MS", html, 1))); info.setTimeLimit(Integer.parseInt(ReUtil.get("(\\d*) MS", html, 1)));
info.setMemoryLimit(Integer.parseInt(ReUtil.get("/(\\d*) K", html, 1)) / 1024); info.setMemoryLimit(Integer.parseInt(ReUtil.get("/(\\d*) K", html, 1)) / 1024);
info.setDescription(ReUtil.get(">Problem Description</div> <div class=.*?>([\\s\\S]*?)</div>", html, 1).replaceAll("src=\"../../", "src=\"" + HOST + "/")); info.setDescription(ReUtil.get(">Problem Description</div> <div class=.*?>([\\s\\S]*?)</div>", html, 1)
.replaceAll("src=\"", "src=\"" + HOST));
info.setInput(ReUtil.get(">Input</div> <div class=.*?>([\\s\\S]*?)</div>", html, 1)); info.setInput(ReUtil.get(">Input</div> <div class=.*?>([\\s\\S]*?)</div>", html, 1));
info.setOutput(ReUtil.get(">Output</div> <div class=.*?>([\\s\\S]*?)</div>", html, 1)); info.setOutput(ReUtil.get(">Output</div> <div class=.*?>([\\s\\S]*?)</div>", html, 1));
StringBuilder sb = new StringBuilder("<input>"); StringBuilder sb = new StringBuilder("<input>");
@ -47,7 +48,7 @@ public class HDUProblemStrategy extends ProblemStrategy {
info.setExamples(sb.toString()); info.setExamples(sb.toString());
info.setHint(ReUtil.get("<i>Hint</i></div>([\\s\\S]*?)</div><i .*?<br><[^<>]*?panel_title[^<>]*?>", html, 1)); info.setHint(ReUtil.get("<i>Hint</i></div>([\\s\\S]*?)</div><i .*?<br><[^<>]*?panel_title[^<>]*?>", html, 1));
info.setIsRemote(true); info.setIsRemote(true);
info.setSource(String.format("<a style='color:#1A5CC8' href='http://acm.hdu.edu.cn/showproblem.php?pid=%s'>%s</a>", problemId, JUDGE_NAME + "-" + problemId)); info.setSource(String.format("<a style='color:#1A5CC8' href='https://acm.hdu.edu.cn/showproblem.php?pid=%s'>%s</a>", problemId, JUDGE_NAME + "-" + problemId));
info.setType(0) info.setType(0)
.setAuth(1) .setAuth(1)
.setAuthor(author) .setAuthor(author)

View File

@ -34,7 +34,7 @@ public class POJProblemStrategy extends ProblemStrategy {
info.setTimeLimit(Integer.parseInt(ReUtil.get("<b>Time Limit:</b> (\\d{3,})MS</td>", html, 1))); info.setTimeLimit(Integer.parseInt(ReUtil.get("<b>Time Limit:</b> (\\d{3,})MS</td>", html, 1)));
info.setMemoryLimit(Integer.parseInt(ReUtil.get("<b>Memory Limit:</b> (\\d{2,})K</td>", html, 1)) / 1024); info.setMemoryLimit(Integer.parseInt(ReUtil.get("<b>Memory Limit:</b> (\\d{2,})K</td>", html, 1)) / 1024);
info.setDescription(ReUtil.get("<p class=\"pst\">Description</p><div class=.*?>([\\s\\S]*?)</div><p class=\"pst\">", html, 1) info.setDescription(ReUtil.get("<p class=\"pst\">Description</p><div class=.*?>([\\s\\S]*?)</div><p class=\"pst\">", html, 1)
.replaceAll("src=\"../../", "src=\"" + HOST + "/")); .replaceAll("src=\"", "src=\"" + HOST + "/"));
info.setInput(ReUtil.get("<p class=\"pst\">Input</p><div class=.*?>([\\s\\S]*?)</div><p class=\"pst\">", html, 1)); info.setInput(ReUtil.get("<p class=\"pst\">Input</p><div class=.*?>([\\s\\S]*?)</div><p class=\"pst\">", html, 1));
info.setOutput(ReUtil.get("<p class=\"pst\">Output</p><div class=.*?>([\\s\\S]*?)</div><p class=\"pst\">", html, 1)); info.setOutput(ReUtil.get("<p class=\"pst\">Output</p><div class=.*?>([\\s\\S]*?)</div><p class=\"pst\">", html, 1));