利用浏览器调试功能 计算 百度网盘 文件数量
生活随笔
收集整理的這篇文章主要介紹了
利用浏览器调试功能 计算 百度网盘 文件数量
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
“百度網盤”程序做的比較爛,以百度的技術實力按說不應該如此。真正試了就知道真的不怎么樣。
? 為了統計百度網盤的文件寫了以下腳本,僅供參考:
var root = "";//指定目錄,空取當前目錄 var totalCount = 0; var startTime = new Date(); function timeSpan(stime, etime) {var usedTime = etime - stime;var days = Math.floor(usedTime / (24 * 3600 * 1000));var leave1 = usedTime % (24 * 3600 * 1000);var hours = Math.floor(leave1 / (3600 * 1000));var leave2 = leave1 % (3600 * 1000);var minutes = Math.floor(leave2 / (60 * 1000));var leave3 = leave2 % (60 * 1000);var seconds = Math.round(leave3 / 1000);var time ="";if(days>0){time+=days+"天";}if(hours>0){time+=hours+"小時";}if(minutes>0){time+=minutes+"分鐘";}time+=seconds+"秒";return time; } (function($){$.getUrlParam = function (name) {var search = document.location.hash;var pattern = new RegExp("[?&]" + name + "\=([^&]+)", "g");var matcher = pattern.exec(search);var items = null;if (null != matcher) {try {items = decodeURIComponent(decodeURIComponent(matcher[1]));} catch (e) {try {items = decodeURIComponent(matcher[1]);} catch (e) {items = matcher[1];}}}return items;} })(jQuery);if(root=="") {root=$.getUrlParam("path"); }function GetFilesCount(fileLists) {var count=0;var fl=fileLists.length;for (var index=0; index<fl; index++) { (function(index) { var file=fileLists[index];if(file.isdir==0){count++;totalCount++;}else if(file.isdir==1){count=count+GetDirFilsCount(file.path);}})(index); } return count; }function GetDirFilsCount(dirName) {var dfCount=0;$.ajax({url: 'https://pan.baidu.com/api/list?dir='+dirName,type: 'get',async: true,//true 異步,false 同步success: function(data) {var fileLists = data.list;dfCount=GetFilesCount(fileLists); console.log(decodeURIComponent(dirName)+":"+dfCount);console.log("統計目錄為:“"+decodeURIComponent(root)+"” 當前計算總數:"+totalCount+" 用時:" +timeSpan(startTime, new Date()));}});return dfCount; }GetDirFilsCount(root);執行過程截圖(異步 測試目錄用時10秒):
執行過程截圖(同步 測試目錄用時49秒):
總結
以上是生活随笔為你收集整理的利用浏览器调试功能 计算 百度网盘 文件数量的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用批处理修复 win10 无法升级的问题
- 下一篇: 利用浏览器调试功能 计算 百度网盘 文件