lyg
2024-06-14 92c1b3abe15b82486427ef2e9e2455524e0c6c84
回写图书信息到Excel
1个文件已修改
11 ■■■■■ 已修改文件
src/main.mjs 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;