fix file name

This commit is contained in:
Niko 2026-05-22 09:42:52 +08:00
parent c4829156a9
commit 2518b922af

View File

@ -79,10 +79,9 @@ public class EtsScraper {
} }
String dateStrFormatted = targetDate.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")); String dateStrFormatted = targetDate.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd"));
String dateStrFileName = targetDate.format(DateTimeFormatter.ofPattern("yyyyMMdd")); String dateStrFileName = targetDate.format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmm"));
Path downloadPath = Path.of("downloads").toAbsolutePath().normalize(); Path savedFile = Path.of("downloads").resolve("三联单列表_" + dateStrFileName + ".xls");
Path savedFile = downloadPath.resolve("三联单列表_" + dateStrFileName + ".xls");
if (java.nio.file.Files.exists(savedFile) && java.nio.file.Files.size(savedFile) > 0) { if (java.nio.file.Files.exists(savedFile) && java.nio.file.Files.size(savedFile) > 0) {
System.out.println("[+] File already exists: " + savedFile); System.out.println("[+] File already exists: " + savedFile);
@ -343,7 +342,7 @@ public class EtsScraper {
private static void screenshot(Page page, String name) { private static void screenshot(Page page, String name) {
try { try {
String timestamp = LocalDateTime.now() String timestamp = LocalDateTime.now()
.format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")); .format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmm"));
Path path = SCREENSHOT_DIR.resolve(name + "_" + timestamp + ".png"); Path path = SCREENSHOT_DIR.resolve(name + "_" + timestamp + ".png");
page.screenshot(new Page.ScreenshotOptions().setPath(path)); page.screenshot(new Page.ScreenshotOptions().setPath(path));
System.out.println("[+] Screenshot saved: " + path); System.out.println("[+] Screenshot saved: " + path);