Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
950f5af5ea | ||
|
|
ec053266a7 |
@@ -15,7 +15,7 @@ from flask import Flask, jsonify, request, send_file, send_from_directory
|
||||
import store
|
||||
import db
|
||||
import notify
|
||||
from engine import CrawlJob, probe_links
|
||||
from engine import CrawlJob, probe_links, normalize_url
|
||||
from scheduler import Scheduler, cron_next, interval_delta
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
@@ -435,6 +435,54 @@ def api_trash_clear():
|
||||
|
||||
# ---------------- API: 运行控制 ----------------
|
||||
|
||||
@app.route("/api/tasks/<tid>/retry-failed", methods=["POST"])
|
||||
def api_retry_failed(tid):
|
||||
"""重爬失败页: 提取指定 run (默认最新) 中失败的 URL, 从已爬集合解除标记并注入
|
||||
待爬队列头部; 返回注入数量, 调用方可随后点「继续爬取」重爬这些页面"""
|
||||
task = store.get_task(tid)
|
||||
if not task:
|
||||
return jsonify({"error": "任务不存在"}), 404
|
||||
if task.get("mode") != "auto":
|
||||
return jsonify({"error": "仅自动模式任务支持重爬失败页"}), 400
|
||||
try:
|
||||
body = request.get_json(force=True) or {}
|
||||
except Exception:
|
||||
body = {}
|
||||
rid = request.args.get("run", "") or body.get("run", "")
|
||||
runs = store.get_runs(tid)
|
||||
cur = None
|
||||
if rid:
|
||||
cur = next((r for r in runs if r["id"] == rid), None)
|
||||
else:
|
||||
cur = runs[-1] if runs else None
|
||||
if not cur:
|
||||
return jsonify({"error": "运行记录不存在"}), 404
|
||||
failed = [res.get("url") for res in cur.get("results", [])
|
||||
if res.get("status") == "FAIL" and res.get("url")]
|
||||
if not failed:
|
||||
return jsonify({"error": "该运行记录没有失败页面", "injected": 0})
|
||||
st = store.load_auto_state(tid, task)
|
||||
visited = set(st.get("visited", []))
|
||||
pending = st.get("pending", [])
|
||||
pending_urls = {normalize_url(p.get("url", "")) for p in pending}
|
||||
# 待重爬: 已爬过且不在待爬队列中的失败 URL (去重)
|
||||
to_inject, seen = [], set()
|
||||
for u in failed:
|
||||
key = normalize_url(u)
|
||||
if key in visited and key not in pending_urls and key not in seen:
|
||||
seen.add(key)
|
||||
to_inject.append({"url": u, "depth": 0, "source": "retry-failed"})
|
||||
if not to_inject:
|
||||
return jsonify({"error": "失败页面均已爬或已在待爬队列中", "injected": 0})
|
||||
# 解除已爬标记
|
||||
remove_keys = {normalize_url(u) for u in failed}
|
||||
visited = {v for v in visited if normalize_url(v) not in remove_keys}
|
||||
# 注入队列头部, 优先重爬
|
||||
pending = to_inject + pending
|
||||
store.save_auto_state(tid, {"pending": pending, "visited": sorted(visited)})
|
||||
return jsonify({"injected": len(to_inject), "pending_total": len(pending)})
|
||||
|
||||
|
||||
@app.route("/api/tasks/<tid>/continue", methods=["POST"])
|
||||
def api_continue(tid):
|
||||
"""继续爬取: auto 任务从待爬缓存队列接着爬 (跳过起始网址, 保留已爬集合)"""
|
||||
|
||||
@@ -30,12 +30,21 @@ IMG_EXTS = (".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp")
|
||||
DEFAULT_UA = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
||||
"(KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36")
|
||||
|
||||
_CHALLENGE_MARKS = [
|
||||
# title 中出现任一标记即判定反爬 (title 短小可靠, 不会误伤正文)
|
||||
_CHALLENGE_TITLE_MARKS = [
|
||||
"access denied", "403 forbidden", "just a moment", "attention required",
|
||||
"captcha", "bot check", "cf-challenge", "verify you are human",
|
||||
"checking your browser", "enable javascript and cookies",
|
||||
]
|
||||
|
||||
# html 中仅匹配强特征标记, 且只在 head 区域(前 20KB)搜索。
|
||||
# 不能全文匹配 "captcha"/"challenge" 等词——正常文章正文提到这些词会被误判为反爬。
|
||||
_CHALLENGE_HTML_MARKS = [
|
||||
"cf-challenge", "challenge-platform", "cf-browser-verification",
|
||||
"verify you are human", "checking your browser",
|
||||
"enable javascript and cookies", "just a moment",
|
||||
]
|
||||
|
||||
# 反爬拦截类错误信号: 命中后不再重试 (重试无意义且拖慢任务)
|
||||
_ANTI_CRAWL_MARKS = [
|
||||
"403", "429", "503", "forbidden", "access denied", "too many requests",
|
||||
@@ -50,14 +59,31 @@ def is_anti_crawl_error(err):
|
||||
return any(m in s for m in _ANTI_CRAWL_MARKS)
|
||||
|
||||
|
||||
_BROWSER_DEAD_MARKS = [
|
||||
"browser has been closed", "target page, context or browser has been closed",
|
||||
"has been disposed", "execution context was destroyed", "browser closed",
|
||||
"page closed", "target closed", "crash",
|
||||
]
|
||||
|
||||
|
||||
def is_browser_dead_error(err):
|
||||
"""判断错误是否属于浏览器/页面失效 (需重启浏览器后重试, 重试同一 URL 才有意义)"""
|
||||
s = str(err or "").lower()
|
||||
return any(m in s for m in _BROWSER_DEAD_MARKS)
|
||||
|
||||
|
||||
def is_challenge_page(title, html):
|
||||
"""判断是否仍在反爬验证页 (仅关键词启发, 避免误伤正常小页面)"""
|
||||
low = html.lower()
|
||||
"""判断是否仍在反爬验证页
|
||||
- title 出现反爬关键词: 判定 (可靠, 反爬页 title 基本都会变)
|
||||
- html 仅在前 20KB(head 区域)出现强特征标记时判定,
|
||||
避免正文含 captcha/challenge 等词的正常页面被误杀
|
||||
"""
|
||||
t = (title or "").lower()
|
||||
for mark in _CHALLENGE_MARKS:
|
||||
if mark in t or mark in low:
|
||||
for mark in _CHALLENGE_TITLE_MARKS:
|
||||
if mark in t:
|
||||
return True
|
||||
return False
|
||||
low = (html or "").lower()[:20000]
|
||||
return any(m in low for m in _CHALLENGE_HTML_MARKS)
|
||||
|
||||
|
||||
def safe_name(url, idx):
|
||||
@@ -231,6 +257,14 @@ class CrawlJob:
|
||||
self._auto_pending = None
|
||||
self._cfg_lock = threading.RLock()
|
||||
self.thread = None
|
||||
# 浏览器句柄 (p, browser, ctx, page, cookie_file); 崩溃后重建
|
||||
self._browser = None
|
||||
|
||||
def _page(self):
|
||||
return self._browser[3] if self._browser else None
|
||||
|
||||
def _ctx(self):
|
||||
return self._browser[2] if self._browser else None
|
||||
|
||||
# ---------------- 控制接口 ----------------
|
||||
def start(self):
|
||||
@@ -309,9 +343,13 @@ class CrawlJob:
|
||||
pass
|
||||
Stealth().apply_stealth_sync(ctx)
|
||||
page = ctx.new_page()
|
||||
return p, browser, ctx, page, cookie_file
|
||||
self._browser = (p, browser, ctx, page, cookie_file)
|
||||
return self._browser
|
||||
|
||||
def _close_browser(self, p, browser, ctx, cookie_file):
|
||||
def _close_browser(self):
|
||||
if not self._browser:
|
||||
return
|
||||
p, browser, ctx, _page, cookie_file = self._browser
|
||||
try:
|
||||
json.dump(ctx.cookies(), open(cookie_file, "w"))
|
||||
except Exception:
|
||||
@@ -324,10 +362,24 @@ class CrawlJob:
|
||||
p.stop()
|
||||
except Exception:
|
||||
pass
|
||||
self._browser = None
|
||||
|
||||
def _reopen_browser(self):
|
||||
"""浏览器失效后重建: 保存 cookie -> 关闭旧实例 -> 启动新实例"""
|
||||
self._close_browser()
|
||||
time.sleep(1)
|
||||
self._open_browser()
|
||||
self._log("info", "浏览器已重启")
|
||||
|
||||
def _need_browser_restart(self, done_count):
|
||||
"""每爬 N 页主动重启一次浏览器, 防止长时间运行内存膨胀导致崩溃 (browser_max_pages=0 关闭)"""
|
||||
limit = int(self._cfg("browser_max_pages", 0) or 0)
|
||||
return limit > 0 and done_count > 1 and (done_count - 1) % limit == 0
|
||||
|
||||
def _wait_page_settle(self, page, timeout_s):
|
||||
last_title, stable = "", 0
|
||||
challenge_hits = 0
|
||||
err_streak = 0 # 连续读取失败计数
|
||||
start = time.time()
|
||||
while time.time() - start < timeout_s:
|
||||
if self._stop.is_set():
|
||||
@@ -338,7 +390,11 @@ class CrawlJob:
|
||||
title = page.title()
|
||||
html = page.content()
|
||||
except Exception:
|
||||
err_streak += 1
|
||||
if err_streak >= 3: # 页面/浏览器已失效, 提前失败而非干等到超时
|
||||
raise RuntimeError("Target page, context or browser has been closed")
|
||||
continue # 正在跳转
|
||||
err_streak = 0
|
||||
if is_challenge_page(title, html):
|
||||
challenge_hits += 1
|
||||
if challenge_hits >= 8: # 持续 8 秒仍是验证页, 判定反爬, 尽早放弃
|
||||
@@ -461,7 +517,9 @@ class CrawlJob:
|
||||
"source_url": source_url, "depth": depth,
|
||||
"images": [], "attempts": 0,
|
||||
}
|
||||
for attempt in range(retries + 1):
|
||||
dead_strikes = 0 # 浏览器失效重建次数 (防止无限重建)
|
||||
attempt = 0
|
||||
while attempt <= retries:
|
||||
if self._stop.is_set():
|
||||
entry["error"] = "任务已终止"
|
||||
break
|
||||
@@ -485,6 +543,22 @@ class CrawlJob:
|
||||
except Exception as e:
|
||||
entry["error"] = str(e)
|
||||
entry["crawl_time"] = store.now_str()
|
||||
if is_browser_dead_error(e):
|
||||
# 浏览器/页面失效: 重启浏览器后重试同一 URL, 不消耗重试次数
|
||||
dead_strikes += 1
|
||||
if dead_strikes > 3:
|
||||
entry["error"] = f"浏览器多次重启仍失效, 放弃: {e}"
|
||||
self._log("error", f"浏览器多次重启仍失效, 放弃 {url}")
|
||||
break
|
||||
self._log("warn", f"浏览器已失效({e}), 重启后重试: {url}")
|
||||
try:
|
||||
self._reopen_browser()
|
||||
page, ctx = self._page(), self._ctx()
|
||||
except Exception as re_err:
|
||||
entry["error"] = f"浏览器重启失败: {re_err}"
|
||||
self._log("error", f"浏览器重启失败, 放弃 {url}: {re_err}")
|
||||
break
|
||||
continue
|
||||
self._log("warn", f"第{attempt + 1}次失败 {url}: {e}")
|
||||
if is_anti_crawl_error(e):
|
||||
# 反爬拦截: 重试也过不去, 直接放弃, 不再消耗重试次数
|
||||
@@ -499,6 +573,7 @@ class CrawlJob:
|
||||
break
|
||||
self._wait_if_paused()
|
||||
time.sleep(0.3)
|
||||
attempt += 1
|
||||
self._write_page_meta(out_dir, base, entry)
|
||||
return entry
|
||||
|
||||
@@ -562,17 +637,20 @@ class CrawlJob:
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
self._persist()
|
||||
|
||||
p, browser, ctx, page, cookie_file = self._open_browser()
|
||||
self._open_browser()
|
||||
try:
|
||||
for i, url in enumerate(urls, 1):
|
||||
if self._stop.is_set():
|
||||
self._log("info", "收到终止信号, 停止爬取")
|
||||
break
|
||||
self._wait_if_paused()
|
||||
if self._need_browser_restart(i):
|
||||
self._log("info", f"已爬 {i - 1} 页, 主动重启浏览器")
|
||||
self._reopen_browser()
|
||||
run["progress"]["current_url"] = url
|
||||
run["progress"]["done"] = i - 1
|
||||
self._persist()
|
||||
entry = self._retry_crawl(page, ctx, url, i, out_dir)
|
||||
entry = self._retry_crawl(self._page(), self._ctx(), url, i, out_dir)
|
||||
run["results"].append(entry)
|
||||
self._bump_stats(entry)
|
||||
run["progress"]["done"] = i
|
||||
@@ -580,7 +658,7 @@ class CrawlJob:
|
||||
if entry["status"] == "OK":
|
||||
self._delay()
|
||||
finally:
|
||||
self._close_browser(p, browser, ctx, cookie_file)
|
||||
self._close_browser()
|
||||
|
||||
def _discover_links(self, page):
|
||||
"""从当前页面提取符合规则的链接"""
|
||||
@@ -637,7 +715,7 @@ class CrawlJob:
|
||||
self._auto_pending = len(queue)
|
||||
self._persist()
|
||||
|
||||
p, browser, ctx, page, cookie_file = self._open_browser()
|
||||
self._open_browser()
|
||||
try:
|
||||
while queue and not self._stop.is_set():
|
||||
self._wait_if_paused()
|
||||
@@ -650,6 +728,9 @@ class CrawlJob:
|
||||
elif len(visited) >= max_pages:
|
||||
self._log("info", f"达到最大页数上限 {max_pages}, 停止")
|
||||
break
|
||||
if self._need_browser_restart(len(visited)):
|
||||
self._log("info", f"已爬 {len(visited) - 1} 页, 主动重启浏览器")
|
||||
self._reopen_browser()
|
||||
url, depth, src = queue.pop(0)
|
||||
key = normalize_url(url)
|
||||
if key in visited and url != seed: # 起始网址不去重, 其余已爬跳过
|
||||
@@ -661,14 +742,14 @@ class CrawlJob:
|
||||
run["progress"]["current_url"] = url
|
||||
run["progress"]["done"] = len(visited)
|
||||
self._persist()
|
||||
entry = self._retry_crawl(page, ctx, url, idx, out_dir,
|
||||
entry = self._retry_crawl(self._page(), self._ctx(), url, idx, out_dir,
|
||||
source_url=src, depth=depth)
|
||||
run["results"].append(entry)
|
||||
self._bump_stats(entry)
|
||||
self._persist()
|
||||
# 无深度限制或未达深度限制时持续发现链接
|
||||
if entry["status"] == "OK" and (max_depth == 0 or depth < max_depth):
|
||||
for link in self._discover_links(page):
|
||||
for link in self._discover_links(self._page()):
|
||||
lk = normalize_url(link)
|
||||
if lk not in visited and lk not in queued:
|
||||
queued.add(lk)
|
||||
@@ -680,7 +761,7 @@ class CrawlJob:
|
||||
if not self._stop.is_set() and len(queue) == 0:
|
||||
self._log("info", f"无新链接可爬, 任务结束 (共 {len(visited)} 页)")
|
||||
finally:
|
||||
self._close_browser(p, browser, ctx, cookie_file)
|
||||
self._close_browser()
|
||||
# 无论完成/停止/异常, 都保存缓存队列与已爬集合, 便于下次继续
|
||||
try:
|
||||
store.save_auto_state(self.task["id"], {
|
||||
|
||||
+99
-8
@@ -3,12 +3,13 @@
|
||||
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const MODE_LABEL = { batch: "批量", scheduled: "定时", auto: "自动" };
|
||||
const DETAIL_PAGE_SIZE = 100; // 详情结果每页条数 (默认)
|
||||
|
||||
const state = {
|
||||
tasks: [],
|
||||
editTask: null, // 正在编辑的任务
|
||||
mode: "batch", // 当前表单模式
|
||||
detail: { task: null, runId: null, logOffset: 0, timer: null },
|
||||
detail: { task: null, runId: null, logOffset: 0, timer: null, pageSize: DETAIL_PAGE_SIZE },
|
||||
logTimer: null,
|
||||
};
|
||||
let formDirty = false; // 新建/编辑表单是否有未保存修改
|
||||
@@ -522,7 +523,6 @@ async function submitForm(e) {
|
||||
}
|
||||
|
||||
/* ---------------- 详情 ---------------- */
|
||||
const DETAIL_PAGE_SIZE = 100; // 详情结果每页条数
|
||||
|
||||
async function openDetail(tid) {
|
||||
try {
|
||||
@@ -531,6 +531,7 @@ async function openDetail(tid) {
|
||||
const runs = t.runs || [];
|
||||
const cur = t.run;
|
||||
state.detail.runId = cur ? cur.id : (runs[0] ? runs[0].id : null);
|
||||
state.detail.pageSize = (t.run && t.run.run_page_size) || DETAIL_PAGE_SIZE;
|
||||
state.detail.logOffset = 0;
|
||||
$("detailTitle").textContent = `任务详情 · ${t.name}`;
|
||||
renderDetail();
|
||||
@@ -539,8 +540,9 @@ async function openDetail(tid) {
|
||||
} catch (e) { toast(e.message, true); }
|
||||
}
|
||||
|
||||
async function loadRunPage(tid, rid, page) {
|
||||
return api(`/api/tasks/${tid}?run=${rid}&page=${page}&page_size=${DETAIL_PAGE_SIZE}`);
|
||||
async function loadRunPage(tid, rid, page, size) {
|
||||
const ps = size || state.detail.pageSize || DETAIL_PAGE_SIZE;
|
||||
return api(`/api/tasks/${tid}?run=${rid}&page=${page}&page_size=${ps}`);
|
||||
}
|
||||
|
||||
async function selectRun(rid) {
|
||||
@@ -550,6 +552,7 @@ async function selectRun(rid) {
|
||||
const d = await loadRunPage(t.id, rid, 1);
|
||||
state.detail.task = d;
|
||||
state.detail.runId = d.run ? d.run.id : null;
|
||||
state.detail.pageSize = (d.run && d.run.run_page_size) || DETAIL_PAGE_SIZE;
|
||||
state.detail.logOffset = 0;
|
||||
renderDetail();
|
||||
startLogPoll();
|
||||
@@ -559,13 +562,82 @@ async function selectRun(rid) {
|
||||
async function goRunPage(p) {
|
||||
const t = state.detail.task;
|
||||
if (!t || !state.detail.runId) return;
|
||||
const ps = (t.run && t.run.run_page_size) || state.detail.pageSize || DETAIL_PAGE_SIZE;
|
||||
try {
|
||||
const d = await loadRunPage(t.id, state.detail.runId, p);
|
||||
const d = await loadRunPage(t.id, state.detail.runId, p, ps);
|
||||
state.detail.task = d;
|
||||
state.detail.pageSize = (d.run && d.run.run_page_size) || ps;
|
||||
renderDetail();
|
||||
} catch (e) { toast(e.message, true); }
|
||||
}
|
||||
|
||||
/* 跳转到指定页码 (输入框回车/点击 GO) */
|
||||
function jumpRunPage() {
|
||||
const t = state.detail.task;
|
||||
if (!t || !state.detail.runId || !t.run) return;
|
||||
const inp = $("pagerJump");
|
||||
const pages = t.run.run_pages || 1;
|
||||
let p = parseInt(inp.value, 10);
|
||||
if (!p || isNaN(p)) p = 1;
|
||||
p = Math.min(Math.max(p, 1), pages);
|
||||
inp.value = p;
|
||||
goRunPage(p);
|
||||
}
|
||||
|
||||
/* 切换每页条数 */
|
||||
async function changePageSize(size) {
|
||||
const t = state.detail.task;
|
||||
if (!t || !state.detail.runId) return;
|
||||
try {
|
||||
const d = await loadRunPage(t.id, state.detail.runId, 1, parseInt(size, 10) || 100);
|
||||
state.detail.task = d;
|
||||
state.detail.pageSize = (d.run && d.run.run_page_size) || 100;
|
||||
renderDetail();
|
||||
} catch (e) { toast(e.message, true); }
|
||||
}
|
||||
|
||||
/* 生成页码窗口列表, 0 表示省略号: 1 2 3 … 97 98 99 100 */
|
||||
function pageWindow(cur, pages, width) {
|
||||
width = width || 5;
|
||||
const win = [];
|
||||
if (pages <= width + 2) {
|
||||
for (let i = 1; i <= pages; i++) win.push(i);
|
||||
return win;
|
||||
}
|
||||
win.push(1);
|
||||
let lo = Math.max(2, cur - Math.floor(width / 2));
|
||||
let hi = Math.min(pages - 1, cur + Math.floor(width / 2));
|
||||
if (hi - lo < width - 1) {
|
||||
if (lo <= 2) hi = lo + width - 1;
|
||||
else lo = hi - width + 1;
|
||||
}
|
||||
if (lo > 2) win.push(0);
|
||||
for (let i = lo; i <= hi; i++) win.push(i);
|
||||
if (hi < pages - 1) win.push(0);
|
||||
win.push(pages);
|
||||
return win;
|
||||
}
|
||||
|
||||
/* 重爬失败页: 注入待爬队列并自动继续爬取 */
|
||||
async function retryFailed() {
|
||||
const t = state.detail.task;
|
||||
if (!t || !state.detail.runId) return;
|
||||
if (!confirm("将把本次运行失败的页面重新加入待爬队列并立即继续爬取,确定?")) return;
|
||||
try {
|
||||
const d = await api(`/api/tasks/${t.id}/retry-failed`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ run: state.detail.runId }),
|
||||
});
|
||||
toast(`已注入 ${d.injected} 个失败页,开始继续爬取…`);
|
||||
if ((d.injected || 0) > 0) {
|
||||
await api(`/api/tasks/${t.id}/continue`, { method: "POST" });
|
||||
}
|
||||
loadTasks();
|
||||
openDetail(t.id);
|
||||
} catch (e) { toast(e.message, true); }
|
||||
}
|
||||
|
||||
function renderDetail() {
|
||||
const t = state.detail.task;
|
||||
const runs = t.runs || [];
|
||||
@@ -664,13 +736,30 @@ function renderRunPanel(t, run) {
|
||||
const total = run.results_total || results.length;
|
||||
const pages = run.run_pages || 1;
|
||||
const page = run.run_page || 1;
|
||||
const pageSize = run.run_page_size || DETAIL_PAGE_SIZE;
|
||||
const multi = pages > 1;
|
||||
const pager = total > 0 ? `
|
||||
<div class="pager">
|
||||
${total > results.length ? `
|
||||
<button class="btn sm" ${page <= 1 ? "disabled" : ""} onclick="goRunPage(${page - 1})">◀ 上一页</button>
|
||||
${multi ? `
|
||||
<button class="btn sm" title="首页" ${page <= 1 ? "disabled" : ""} onclick="goRunPage(1)">⏮</button>
|
||||
<button class="btn sm" title="上一页" ${page <= 1 ? "disabled" : ""} onclick="goRunPage(${page - 1})">◀</button>
|
||||
<span class="pager-pages">${pageWindow(page, pages).map((p) => p === 0
|
||||
? '<span class="pager-ellipsis">…</span>'
|
||||
: `<button class="btn sm page-btn ${p === page ? "active" : ""}" onclick="goRunPage(${p})">${p}</button>`).join("")}</span>
|
||||
<button class="btn sm" title="下一页" ${page >= pages ? "disabled" : ""} onclick="goRunPage(${page + 1})">▶</button>
|
||||
<button class="btn sm" title="末页" ${page >= pages ? "disabled" : ""} onclick="goRunPage(${pages})">⏭</button>
|
||||
<span class="pager-info">第 <b>${page}</b> / ${pages} 页 · 共 ${total} 条</span>
|
||||
<button class="btn sm" ${page >= pages ? "disabled" : ""} onclick="goRunPage(${page + 1})">下一页 ▶</button>`
|
||||
<span class="pager-jump">跳至
|
||||
<input type="number" id="pagerJump" min="1" max="${pages}" value="${page}"
|
||||
onkeydown="if(event.key==='Enter')jumpRunPage()"> 页
|
||||
<button class="btn sm" onclick="jumpRunPage()">GO</button>
|
||||
</span>`
|
||||
: `<span class="pager-info">共 ${total} 条</span>`}
|
||||
<span class="pager-size">每页
|
||||
<select id="pagerSize" onchange="changePageSize(this.value)">
|
||||
${[50, 100, 200, 500].map((s) => `<option value="${s}" ${s === pageSize ? "selected" : ""}>${s}</option>`).join("")}
|
||||
</select> 条
|
||||
</span>
|
||||
</div>` : "";
|
||||
|
||||
return `
|
||||
@@ -683,6 +772,8 @@ function renderRunPanel(t, run) {
|
||||
<span class="ok">✅ ${s.ok}</span>
|
||||
<span class="fail">❌ ${s.fail}</span>
|
||||
<span class="img">🖼️ ${s.images}</span>
|
||||
${t.mode === "auto" && (s.fail || 0) > 0 && run.status !== "running" && run.status !== "paused" ? `
|
||||
<button class="btn sm" title="将本次运行失败的页面重新加入待爬队列并继续爬取" onclick="retryFailed()">🔄 重爬失败页 (${s.fail})</button>` : ""}
|
||||
</div>
|
||||
${prog}
|
||||
<div class="card-line">当前: <b>${esc(run.progress.current_url || "")}</b></div>
|
||||
|
||||
@@ -287,3 +287,20 @@ td.title-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
|
||||
}
|
||||
.pager-info { color: var(--text-dim, #999); font-size: 13px; }
|
||||
.pager .btn:disabled { opacity: 0.4; cursor: not-allowed; }
|
||||
.pager-pages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
|
||||
.pager-pages .page-btn { min-width: 30px; padding: 4px 6px; }
|
||||
.pager-pages .page-btn.active {
|
||||
background: var(--accent, #2d6cdf);
|
||||
color: #fff;
|
||||
border-color: var(--accent, #2d6cdf);
|
||||
font-weight: 600;
|
||||
}
|
||||
.pager-ellipsis { color: var(--text-dim, #999); padding: 0 2px; user-select: none; }
|
||||
.pager-jump { display: inline-flex; align-items: center; gap: 4px; color: var(--text-dim, #999); font-size: 13px; }
|
||||
.pager-jump input {
|
||||
width: 56px;
|
||||
padding: 3px 6px;
|
||||
text-align: center;
|
||||
}
|
||||
.pager-size { display: inline-flex; align-items: center; gap: 4px; color: var(--text-dim, #999); font-size: 13px; }
|
||||
.pager-size select { padding: 3px 4px; width: auto; }
|
||||
Reference in New Issue
Block a user