From 92c1b3abe15b82486427ef2e9e2455524e0c6c84 Mon Sep 17 00:00:00 2001 From: lyg <1543117173@qq.com> Date: 星期五, 14 六月 2024 23:01:48 +0800 Subject: [PATCH] 回写图书信息到Excel --- src/main.mjs | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.mjs b/src/main.mjs index e6bca2b..bbf02b6 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -482,9 +482,9 @@ function getBookInfo(book) { return retry(async () => { - book.publisher = await driver.executeScript(`return document.querySelector("span[itemprop=publisher]").textContent`).catch(e=>0); - book.pubDate = await driver.executeScript(`return document.querySelector("span[itemprop=datePublished]").textContent`).catch(e=>0); - let pages = await driver.executeScript(`return document.querySelector("span[data-id=resultsCount]").textContent`).catch(e=>0); + book.publisher = await driver.executeScript(`return document.querySelector("span[itemprop=publisher]").textContent`).catch(e => 0); + book.pubDate = await driver.executeScript(`return document.querySelector("span[itemprop=datePublished]").textContent`).catch(e => 0); + let pages = await driver.executeScript(`return document.querySelector("span[data-id=resultsCount]").textContent`).catch(e => 0); if (pages) { book.pages = pages.split(' / ')[1]; } }); } @@ -548,7 +548,7 @@ try { await downloadFile(book, url); console.log(`涓嬭浇瀹屾垚: ${book.id} ${book.title}`); - console.log('finish: '+JSON.stringify(book)); + console.log('finish: ' + JSON.stringify(book)); } catch (e) { } successCount++; // 绛変竴娈垫椂闂村啀涓嬩竴涓� @@ -564,6 +564,9 @@ for (const book of books) { const index = data.findIndex((row) => row[0] === book.id); if (index > -1) { + data[index][5] = book.publisher; + data[index][6] = book.pubDate; + data[index][11] = book.pages; data[index][12] = book.state; data[index][13] = book.format; data[index][14] = book.file; -- Gitblit v1.9.1