fix 再多滑一点
Browse files- ocr/getdata.py +6 -6
ocr/getdata.py
CHANGED
|
@@ -375,7 +375,7 @@ def _enter_image_mode(driver: webdriver.Chrome) -> None:
|
|
| 375 |
def main() -> int:
|
| 376 |
ap = argparse.ArgumentParser()
|
| 377 |
ap.add_argument("--book-id", default="SWX0005")
|
| 378 |
-
ap.add_argument("--chapter", default="第
|
| 379 |
ap.add_argument("--out", default="out")
|
| 380 |
ap.add_argument("--headless", action="store_true")
|
| 381 |
ap.add_argument("--timeout", type=int, default=20000)
|
|
@@ -419,7 +419,7 @@ def main() -> int:
|
|
| 419 |
|
| 420 |
clicked = False
|
| 421 |
no_scroll_count = 0
|
| 422 |
-
for scroll_attempts in range(
|
| 423 |
try:
|
| 424 |
els = driver.find_elements(By.LINK_TEXT, args.chapter)
|
| 425 |
if not els:
|
|
@@ -453,7 +453,7 @@ def main() -> int:
|
|
| 453 |
var d = els[i];
|
| 454 |
if (d.scrollHeight > d.clientHeight && window.getComputedStyle(d).overflowY !== "hidden") {
|
| 455 |
var before = d.scrollTop;
|
| 456 |
-
d.scrollBy(0,
|
| 457 |
if (d.scrollTop > before) {
|
| 458 |
scrolledAny = true;
|
| 459 |
}
|
|
@@ -463,14 +463,14 @@ def main() -> int:
|
|
| 463 |
''')
|
| 464 |
if not scrolled:
|
| 465 |
no_scroll_count += 1
|
| 466 |
-
if no_scroll_count >=
|
| 467 |
-
print(f"[DEBUG] Reached the bottom of the list (tried
|
| 468 |
break
|
| 469 |
else:
|
| 470 |
no_scroll_count = 0
|
| 471 |
except Exception:
|
| 472 |
pass
|
| 473 |
-
time.sleep(1)
|
| 474 |
|
| 475 |
if clicked:
|
| 476 |
print(f"[DEBUG] Clicked {args.chapter}, waiting for new network data...")
|
|
|
|
| 375 |
def main() -> int:
|
| 376 |
ap = argparse.ArgumentParser()
|
| 377 |
ap.add_argument("--book-id", default="SWX0005")
|
| 378 |
+
ap.add_argument("--chapter", default="第三十七回")
|
| 379 |
ap.add_argument("--out", default="out")
|
| 380 |
ap.add_argument("--headless", action="store_true")
|
| 381 |
ap.add_argument("--timeout", type=int, default=20000)
|
|
|
|
| 419 |
|
| 420 |
clicked = False
|
| 421 |
no_scroll_count = 0
|
| 422 |
+
for scroll_attempts in range(200):
|
| 423 |
try:
|
| 424 |
els = driver.find_elements(By.LINK_TEXT, args.chapter)
|
| 425 |
if not els:
|
|
|
|
| 453 |
var d = els[i];
|
| 454 |
if (d.scrollHeight > d.clientHeight && window.getComputedStyle(d).overflowY !== "hidden") {
|
| 455 |
var before = d.scrollTop;
|
| 456 |
+
d.scrollBy(0, 800);
|
| 457 |
if (d.scrollTop > before) {
|
| 458 |
scrolledAny = true;
|
| 459 |
}
|
|
|
|
| 463 |
''')
|
| 464 |
if not scrolled:
|
| 465 |
no_scroll_count += 1
|
| 466 |
+
if no_scroll_count >= 15:
|
| 467 |
+
print(f"[DEBUG] Reached the bottom of the list (tried 15 times). {args.chapter} not found.")
|
| 468 |
break
|
| 469 |
else:
|
| 470 |
no_scroll_count = 0
|
| 471 |
except Exception:
|
| 472 |
pass
|
| 473 |
+
time.sleep(1.5)
|
| 474 |
|
| 475 |
if clicked:
|
| 476 |
print(f"[DEBUG] Clicked {args.chapter}, waiting for new network data...")
|