源英 發問時間: 電腦與網際網路其他:電腦 · 4 星期前

請問程式高手,下面網站的小說有二千多回,如何才能一次下載到電腦中 vb如何寫?謝謝! https://www.x81zw.com/book/31/31897/21612427.html?

已更新項目:

很高興看到您的答案,但我還是不會用,可否寫出全部的操作過程,先給您按五顆星表示感謝。

2 個已更新項目:

我已安裝了google chrome瀏覽器了

下一步如何做呀?

3 個已更新項目:

我也按了f12,也看到了console 它裡面有一大串的資料在,把它殺了嗎?再將您的程式碼貼上嗎?

4 個已更新項目:

我試著貼上,並沒有看到有下載全部文章的動作。謝謝!

5 個已更新項目:

貼上您的程式後,首先出現的是:

Promise {<pending>}

VM50:1 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://www.x81zw.com/book/31/31897/ with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032... for more details.

6 個已更新項目:

下面接著出現的文字如下:

Access to fetch at 'https://www.x81zw.com/book/31/31897/' from origin 'chrome-search://local-ntp' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

local-ntp.html:1 Uncaught (in promise) TypeError: Failed to fetch

Promise.then (async)

(anonymous) @ VM50:1

1 個解答

評分
  • 匿名使用者
    4 星期前
    最佳解答

    請使用google chrome瀏覽器

    我寫了一個javascript程式,打開F12將程式碼貼在console裡面按Enter,

    全部的章節就會一次下載完成

    fetch("https://www.x81zw.com/book/31/31897/").then(e => e.text()).then(e => {

     var doc = new DOMParser().parseFromString(e, "text/html");

     var alldd = Array.from(doc.querySelectorAll("#list dd a"));

     (async function recur(i){

      if(i == alldd.length) return;

      try{

       console.log(`Tryna download episode ${alldd[i].innerText}`);

       var innerDoc = await fetch(alldd[i].href);

       innerDoc = await innerDoc.text();

       innerDoc = new DOMParser().parseFromString(innerDoc, "text/html");

       var a = document.createElement("a");

       a.href = URL.createObjectURL(new Blob([innerDoc.querySelector("#content").innerHTML.replace(/\<br\>/gm, "\n")], {type: "plain/text"}));

       a.download = `${alldd[i].innerText}.txt`;

       a.click();

       return recur(i+1);

      }

      catch(e){

       console.log(e);

       return recur(i+1);

      }

     })(0);

    });

    參考資料: 我不會VB
還有問題?馬上發問,尋求解答。