w-dwdata-hub 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/w-dwdata-hub.umd.js +2 -2
  2. package/dist/w-dwdata-hub.umd.js.map +1 -1
  3. package/docs/WDwdataHub.mjs.html +1 -1
  4. package/docs/decodeEntities.mjs.html +1 -1
  5. package/docs/extractDivContent.mjs.html +1 -1
  6. package/docs/fetchAiNewsAggregator.mjs.html +2 -2
  7. package/docs/fetchAisixiang.mjs.html +13 -13
  8. package/docs/fetchCnyes.mjs.html +8 -8
  9. package/docs/fetchGuancha.mjs.html +15 -15
  10. package/docs/fetchHackerNews.mjs.html +2 -2
  11. package/docs/fetchMoneydj.mjs.html +4 -4
  12. package/docs/fetchMops.mjs.html +14 -14
  13. package/docs/fetchRSS.mjs.html +2 -2
  14. package/docs/fetchStatementdog.mjs.html +6 -6
  15. package/docs/fetchTaifex.mjs.html +14 -14
  16. package/docs/fetchTpex3insti.mjs.html +5 -5
  17. package/docs/fetchTpexMargin.mjs.html +5 -5
  18. package/docs/fetchTpexStock.mjs.html +4 -4
  19. package/docs/fetchTwDataHoliday.mjs.html +2 -2
  20. package/docs/fetchTwseMargin.mjs.html +5 -5
  21. package/docs/fetchTwseStock.mjs.html +4 -4
  22. package/docs/fetchTwseT86.mjs.html +5 -5
  23. package/docs/fetchWithRetry.mjs.html +7 -7
  24. package/docs/getOptFetch.mjs.html +9 -9
  25. package/docs/global.html +29 -29
  26. package/docs/htmlToMarkdown.mjs.html +1 -1
  27. package/docs/index.html +1 -1
  28. package/docs/isYmd.mjs.html +1 -1
  29. package/docs/parseIntComma.mjs.html +1 -1
  30. package/docs/safeFilename.mjs.html +1 -1
  31. package/docs/stripHtml.mjs.html +1 -1
  32. package/docs/toDatetimeUTC8.mjs.html +1 -1
  33. package/docs/toRocDate.mjs.html +1 -1
  34. package/g.mjs +13 -13
  35. package/package.json +5 -5
  36. package/src/fetchAiNewsAggregator.mjs +1 -1
  37. package/src/fetchAisixiang.mjs +12 -12
  38. package/src/fetchCnyes.mjs +7 -7
  39. package/src/fetchGuancha.mjs +14 -14
  40. package/src/fetchHackerNews.mjs +1 -1
  41. package/src/fetchMoneydj.mjs +3 -3
  42. package/src/fetchMops.mjs +13 -13
  43. package/src/fetchRSS.mjs +1 -1
  44. package/src/fetchStatementdog.mjs +5 -5
  45. package/src/fetchTaifex.mjs +13 -13
  46. package/src/fetchTpex3insti.mjs +4 -4
  47. package/src/fetchTpexMargin.mjs +4 -4
  48. package/src/fetchTpexStock.mjs +3 -3
  49. package/src/fetchTwDataHoliday.mjs +1 -1
  50. package/src/fetchTwseMargin.mjs +4 -4
  51. package/src/fetchTwseStock.mjs +3 -3
  52. package/src/fetchTwseT86.mjs +4 -4
  53. package/src/fetchWithRetry.mjs +6 -6
  54. package/src/getOptFetch.mjs +8 -8
  55. package/test/fetchAiNewsAggregator.test.mjs +5 -5
  56. package/test/fetchAisixiang.test.mjs +1 -1
  57. package/test/fetchCnyes.test.mjs +5 -5
  58. package/test/fetchGuancha.test.mjs +1 -1
  59. package/test/fetchHackerNews.test.mjs +5 -5
  60. package/test/fetchMoneydj.test.mjs +1 -1
  61. package/test/fetchMops.test.mjs +2 -2
  62. package/test/fetchRSS.test.mjs +11 -11
  63. package/test/fetchStatementdog.test.mjs +1 -1
  64. package/test/fetchTaifex.test.mjs +1 -1
  65. package/test/fetchTpex3insti.test.mjs +1 -1
  66. package/test/fetchTpexMargin.test.mjs +1 -1
  67. package/test/fetchTpexStock.test.mjs +1 -1
  68. package/test/fetchTwDataHoliday.test.mjs +1 -1
  69. package/test/fetchTwseMargin.test.mjs +1 -1
  70. package/test/fetchTwseStock.test.mjs +1 -1
  71. package/test/fetchTwseT86.test.mjs +1 -1
  72. package/test/fetchWithRetry.test.mjs +1 -1
@@ -124,7 +124,7 @@ function getCfg(opt = {}) {
124
124
  maxPages = Math.min(cint(maxPages), MAX_PAGES)
125
125
  }
126
126
 
127
- return { baseUrl, showLog: optFetch.showLog, pageDelayMs, maxPages, optFetch }
127
+ return { baseUrl, useShowLog: optFetch.useShowLog, pageDelayMs, maxPages, optFetch }
128
128
  }
129
129
 
130
130
 
@@ -302,7 +302,7 @@ async function fetchAllSearchPages(buildUrl, parser, cfg) {
302
302
  for (let page = 1; page <= cfg.maxPages; page++) {
303
303
 
304
304
  let url = buildUrl(page)
305
- if (cfg.showLog) {
305
+ if (cfg.useShowLog) {
306
306
  process.stderr.write(`[info] fetching page ${page}${totalPages > 1 ? `/${totalPages}` : ''} ...\n`)
307
307
  }
308
308
  let html = await fetchWithRetry(url, cfg.optFetch)
@@ -315,7 +315,7 @@ async function fetchAllSearchPages(buildUrl, parser, cfg) {
315
315
  let items = parser(html, cfg.baseUrl)
316
316
  let fresh = items.filter((it) => !seen.has(it.aid))
317
317
  if (fresh.length === 0) {
318
- if (cfg.showLog) {
318
+ if (cfg.useShowLog) {
319
319
  process.stderr.write(`[info] page ${page} 無新項目,停止翻頁\n`)
320
320
  }
321
321
  break
@@ -348,7 +348,7 @@ async function fetchAllSearchPages(buildUrl, parser, cfg) {
348
348
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,預設5
349
349
  * @param {Integer} [opt.pageDelayMs=1000] 輸入翻頁之頁間延遲毫秒整數,預設1000
350
350
  * @param {Integer} [opt.maxPages=50] 輸入翻頁上限正整數,上限為50,預設50
351
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
351
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
352
352
  * @returns {Promise} 回傳Promise,resolve回傳作者物件陣列,各物件為{slug,name}
353
353
  * @example
354
354
  *
@@ -428,7 +428,7 @@ function lookupAuthor(authors, name) {
428
428
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,預設5
429
429
  * @param {Integer} [opt.pageDelayMs=1000] 輸入翻頁之頁間延遲毫秒整數,預設1000
430
430
  * @param {Integer} [opt.maxPages=50] 輸入翻頁上限正整數,上限為50,預設50
431
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
431
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
432
432
  * @returns {Promise} 回傳Promise,resolve回傳主題物件陣列,各物件為{id,name,category}
433
433
  * @example
434
434
  *
@@ -521,7 +521,7 @@ function lookupTopic(topics, name) {
521
521
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,預設5
522
522
  * @param {Integer} [opt.pageDelayMs=1000] 輸入翻頁之頁間延遲毫秒整數,預設1000
523
523
  * @param {Integer} [opt.maxPages=50] 輸入翻頁上限正整數,上限為50,預設50
524
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
524
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
525
525
  * @returns {Promise} 回傳Promise,resolve回傳結果物件{status,site,mode,query,resolved,fetched_at,count,items},name與slug皆未給時reject回傳錯誤物件
526
526
  * @example
527
527
  *
@@ -563,7 +563,7 @@ async function fetchAuthorArticles(opt = {}) {
563
563
 
564
564
  if (!usedSlug) {
565
565
 
566
- if (cfg.showLog) {
566
+ if (cfg.useShowLog) {
567
567
  process.stderr.write('[info] fetching authors list from /thinktank/ ...\n')
568
568
  }
569
569
  let authors = await fetchAuthorsList(opt)
@@ -631,7 +631,7 @@ async function fetchAuthorArticles(opt = {}) {
631
631
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,預設5
632
632
  * @param {Integer} [opt.pageDelayMs=1000] 輸入翻頁之頁間延遲毫秒整數,預設1000
633
633
  * @param {Integer} [opt.maxPages=50] 輸入翻頁上限正整數,上限為50,預設50
634
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
634
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
635
635
  * @returns {Promise} 回傳Promise,resolve回傳結果物件{status,site,mode,query,resolved,fetched_at,count,items},keyword非有效字串時reject回傳錯誤物件
636
636
  * @example
637
637
  *
@@ -703,7 +703,7 @@ async function fetchKeywordArticles(keyword, opt = {}) {
703
703
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,預設5
704
704
  * @param {Integer} [opt.pageDelayMs=1000] 輸入翻頁之頁間延遲毫秒整數,預設1000
705
705
  * @param {Integer} [opt.maxPages=50] 輸入翻頁上限正整數,上限為50,預設50
706
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
706
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
707
707
  * @returns {Promise} 回傳Promise,resolve回傳結果物件{status,site,mode,query,resolved,fetched_at,count,items},keyword非有效字串時reject回傳錯誤物件
708
708
  * @example
709
709
  *
@@ -777,7 +777,7 @@ async function fetchTitleArticles(keyword, opt = {}) {
777
777
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,預設5
778
778
  * @param {Integer} [opt.pageDelayMs=1000] 輸入翻頁之頁間延遲毫秒整數,預設1000
779
779
  * @param {Integer} [opt.maxPages=50] 輸入翻頁上限正整數,上限為50,預設50
780
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
780
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
781
781
  * @returns {Promise} 回傳Promise,resolve回傳結果物件{status,site,mode,query,resolved,fetched_at,count,items},keyword與id皆未給時reject回傳錯誤物件
782
782
  * @example
783
783
  *
@@ -819,7 +819,7 @@ async function fetchTopicArticles(opt = {}) {
819
819
 
820
820
  if (!topicId) {
821
821
 
822
- if (cfg.showLog) {
822
+ if (cfg.useShowLog) {
823
823
  process.stderr.write('[info] fetching topics list from /zhuanti/ ...\n')
824
824
  }
825
825
  let topics = await fetchTopicsList(opt)
@@ -894,7 +894,7 @@ async function fetchTopicArticles(opt = {}) {
894
894
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,預設5
895
895
  * @param {Integer} [opt.pageDelayMs=1000] 輸入翻頁之頁間延遲毫秒整數,預設1000
896
896
  * @param {Integer} [opt.maxPages=50] 輸入翻頁上限正整數,上限為50,預設50
897
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
897
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
898
898
  * @returns {Promise} 回傳Promise,resolve回傳結果物件{status,site,mode,url,title,chars,markdown},aid與url皆未給或解析失敗時reject回傳錯誤物件
899
899
  * @example
900
900
  *
@@ -1025,7 +1025,7 @@ export default fetchAisixiang
1025
1025
  <br class="clear">
1026
1026
 
1027
1027
  <footer>
1028
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 19:16:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1028
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sun Sep 13 2026 14:29:36 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1029
1029
  </footer>
1030
1030
 
1031
1031
  <script>prettyPrint();</script>
@@ -99,7 +99,7 @@ let DEFAULT_DAYS_BACK = 10
99
99
  * @param {Integer} [opt.maxRetries=10] 輸入最大重試次數整數,含初始共執行maxRetries+1次,預設10
100
100
  * @param {Integer} [opt.baseDelayMs=5000] 輸入重試之線性退避基礎毫秒整數,預設5000
101
101
  * @param {Integer} [opt.maxDelayMs=30000] 輸入重試之線性退避上限毫秒整數,預設30000
102
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
102
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
103
103
  * @returns {Promise} 回傳Promise,resolve回傳新聞物件陣列,各物件為{time,title,link},抓取失敗時reject回傳錯誤物件
104
104
  * @example
105
105
  *
@@ -164,13 +164,13 @@ async function fetchCnyes(opt = {}) {
164
164
 
165
165
  //optFetch
166
166
  let optFetch = getOptFetch(opt, DFLT)
167
- let showLog = optFetch.showLog
167
+ let useShowLog = optFetch.useShowLog
168
168
 
169
169
  //now, startAt
170
170
  let now = Math.floor(Date.now() / 1000)
171
171
  let startAt = now - 86400 * daysBack
172
172
 
173
- if (showLog) {
173
+ if (useShowLog) {
174
174
  console.log('Starting to fetch Anue (tw_stock) news...')
175
175
  }
176
176
 
@@ -193,14 +193,14 @@ async function fetchCnyes(opt = {}) {
193
193
  //items
194
194
  let items = get(data, 'items.data')
195
195
  if (!isearr(items)) {
196
- if (showLog) {
196
+ if (useShowLog) {
197
197
  console.log('No more items found.')
198
198
  }
199
199
  break
200
200
  }
201
201
 
202
202
  allItems = allItems.concat(items)
203
- if (showLog) {
203
+ if (useShowLog) {
204
204
  console.log(`Page ${page}: Fetched ${items.length} items. Total so far: ${allItems.length}`)
205
205
  }
206
206
  page++
@@ -211,7 +211,7 @@ async function fetchCnyes(opt = {}) {
211
211
 
212
212
  //finalItems
213
213
  let finalItems = allItems.slice(0, targetTotal)
214
- if (showLog) {
214
+ if (useShowLog) {
215
215
  console.log(`Total items collected: ${finalItems.length}`)
216
216
  }
217
217
 
@@ -219,7 +219,7 @@ async function fetchCnyes(opt = {}) {
219
219
 
220
220
  //time, 單筆publishAt缺漏或異常時退回空字串並記錄, 保留title與link避免拖垮其餘正常新聞
221
221
  let time = toDatetimeUTC8(get(item, 'publishAt', 0))
222
- if (time === '' &amp;&amp; showLog) {
222
+ if (time === '' &amp;&amp; useShowLog) {
223
223
  console.warn(`[fetch-cnyes] 時間格式化失敗(newsId=${get(item, 'newsId', '')}, publishAt=${get(item, 'publishAt', '')}) — 該筆time退回空字串`)
224
224
  }
225
225
 
@@ -247,7 +247,7 @@ export default fetchCnyes
247
247
  <br class="clear">
248
248
 
249
249
  <footer>
250
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 19:16:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
250
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sun Sep 13 2026 14:29:36 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
251
251
  </footer>
252
252
 
253
253
  <script>prettyPrint();</script>
@@ -160,10 +160,10 @@ function getCfg(opt = {}) {
160
160
  timeoutMs = cint(timeoutMs)
161
161
  }
162
162
 
163
- //showLog
164
- let showLog = get(opt, 'showLog')
165
- if (!isbol(showLog)) {
166
- showLog = true
163
+ //useShowLog
164
+ let useShowLog = get(opt, 'useShowLog')
165
+ if (!isbol(useShowLog)) {
166
+ useShowLog = true
167
167
  }
168
168
 
169
169
  //optFetch
@@ -190,7 +190,7 @@ function getCfg(opt = {}) {
190
190
  maxPages = Math.min(cint(maxPages), MAX_PAGES)
191
191
  }
192
192
 
193
- return { baseUrl, showLog, pageDelayMs, maxPages, optFetch }
193
+ return { baseUrl, useShowLog, pageDelayMs, maxPages, optFetch }
194
194
  }
195
195
 
196
196
 
@@ -363,7 +363,7 @@ async function fetchAllListPages(slug, cfg) {
363
363
  for (let page = 1; page &lt;= cfg.maxPages; page++) {
364
364
 
365
365
  let url = `${cfg.baseUrl}/${slug}/list_${page}.shtml`
366
- if (cfg.showLog) {
366
+ if (cfg.useShowLog) {
367
367
  process.stderr.write(`[info] fetching ${slug} list_${page} ...\n`)
368
368
  }
369
369
 
@@ -376,7 +376,7 @@ async function fetchAllListPages(slug, cfg) {
376
376
  if (page === 1) {
377
377
  throw err
378
378
  }
379
- if (cfg.showLog) {
379
+ if (cfg.useShowLog) {
380
380
  process.stderr.write(`[info] page ${page} fetch error (assumed end of list): ${err.message}\n`)
381
381
  }
382
382
  break
@@ -389,7 +389,7 @@ async function fetchAllListPages(slug, cfg) {
389
389
  err.reason = 'redirected-to-homepage'
390
390
  throw err
391
391
  }
392
- if (cfg.showLog) {
392
+ if (cfg.useShowLog) {
393
393
  process.stderr.write(`[info] page ${page} 被導向首頁,視為到底,停止翻頁\n`)
394
394
  }
395
395
  break
@@ -400,7 +400,7 @@ async function fetchAllListPages(slug, cfg) {
400
400
  let items = parseListPage(html, cfg.baseUrl)
401
401
  let fresh = items.filter((it) => !seen.has(it.url))
402
402
  if (fresh.length === 0) {
403
- if (cfg.showLog) {
403
+ if (cfg.useShowLog) {
404
404
  process.stderr.write(`[info] page ${page} 無新項目,停止翻頁\n`)
405
405
  }
406
406
  break
@@ -431,7 +431,7 @@ async function fetchAllListPages(slug, cfg) {
431
431
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,預設5
432
432
  * @param {Integer} [opt.pageDelayMs=1000] 輸入翻頁之頁間延遲毫秒整數,預設1000
433
433
  * @param {Integer} [opt.maxPages=50] 輸入翻頁上限正整數,上限為50,預設50
434
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
434
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
435
435
  * @returns {Promise} 回傳Promise,resolve回傳作者物件陣列,各物件為{slug,name,letter}
436
436
  * @example
437
437
  *
@@ -524,7 +524,7 @@ function lookupTopic(name) {
524
524
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,預設5
525
525
  * @param {Integer} [opt.pageDelayMs=1000] 輸入翻頁之頁間延遲毫秒整數,預設1000
526
526
  * @param {Integer} [opt.maxPages=50] 輸入翻頁上限正整數,上限為50,預設50
527
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
527
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
528
528
  * @returns {Promise} 回傳Promise,resolve回傳結果物件{status,site,mode,query,resolved,fetched_at,count,items},name與slug皆未給時reject回傳錯誤物件
529
529
  * @example
530
530
  *
@@ -565,7 +565,7 @@ async function fetchAuthorArticles(opt = {}) {
565
565
 
566
566
  if (!resolvedSlug) {
567
567
 
568
- if (cfg.showLog) {
568
+ if (cfg.useShowLog) {
569
569
  process.stderr.write('[info] fetching authors index from / ...\n')
570
570
  }
571
571
  let authors = await fetchAuthorsList(opt)
@@ -732,7 +732,7 @@ async function fetchTitleArticles(keyword, opt = {}) {
732
732
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,預設5
733
733
  * @param {Integer} [opt.pageDelayMs=1000] 輸入翻頁之頁間延遲毫秒整數,預設1000
734
734
  * @param {Integer} [opt.maxPages=50] 輸入翻頁上限正整數,上限為50,預設50
735
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
735
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
736
736
  * @returns {Promise} 回傳Promise,resolve回傳結果物件{status,site,mode,query,resolved,fetched_at,count,items},name與slug皆未給時reject回傳錯誤物件
737
737
  * @example
738
738
  *
@@ -837,7 +837,7 @@ async function fetchTopicArticles(opt = {}) {
837
837
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,預設5
838
838
  * @param {Integer} [opt.pageDelayMs=1000] 輸入翻頁之頁間延遲毫秒整數,預設1000
839
839
  * @param {Integer} [opt.maxPages=50] 輸入翻頁上限正整數,上限為50,預設50
840
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
840
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
841
841
  * @returns {Promise} 回傳Promise,resolve回傳結果物件{status,site,mode,url,title,author,published,chars,markdown},url非有效字串時reject回傳錯誤物件
842
842
  * @example
843
843
  *
@@ -990,7 +990,7 @@ export default fetchGuancha
990
990
  <br class="clear">
991
991
 
992
992
  <footer>
993
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 19:16:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
993
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sun Sep 13 2026 14:29:36 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
994
994
  </footer>
995
995
 
996
996
  <script>prettyPrint();</script>
@@ -88,7 +88,7 @@ let CONCURRENCY = 10
88
88
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,含初始共執行maxRetries+1次,預設5
89
89
  * @param {Integer} [opt.baseDelayMs=3000] 輸入重試之線性退避基礎毫秒整數,預設3000
90
90
  * @param {Integer} [opt.maxDelayMs=15000] 輸入重試之線性退避上限毫秒整數,預設15000
91
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示重試訊息布林值,預設true
91
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示重試訊息布林值,預設true
92
92
  * @returns {Promise} 回傳Promise,resolve回傳文章物件陣列,各物件為{url,time,title,description,from},抓取ID清單失敗時reject回傳錯誤物件
93
93
  * @example
94
94
  *
@@ -176,7 +176,7 @@ export default fetchHackerNews
176
176
  <br class="clear">
177
177
 
178
178
  <footer>
179
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 19:16:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
179
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sun Sep 13 2026 14:29:36 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
180
180
  </footer>
181
181
 
182
182
  <script>prettyPrint();</script>
@@ -100,7 +100,7 @@ let REG_TIME = /^(\d{2}\/\d{2}\s+\d{2}:\d{2}|\d{2}:\d{2}|昨\s*\d{2}:\d{2})$/
100
100
  * @param {Integer} [opt.maxDelayMs=30000] 輸入重試最大延遲毫秒整數,預設30000
101
101
  * @param {Integer} [opt.pageDelayMs] 輸入頁間延遲毫秒整數,未給時採隨機1000至3000毫秒
102
102
  * @param {Function} [opt.onPageDone] 輸入每頁完成時之回呼函數,傳入(pageIndex,itemCount,totalPages)
103
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
103
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
104
104
  * @returns {Promise} 回傳Promise,resolve回傳新聞物件陣列,各物件為{time,title,link},抓取到0筆時reject回傳錯誤物件
105
105
  * @example
106
106
  *
@@ -144,7 +144,7 @@ async function fetchMoneydj(opt = {}) {
144
144
 
145
145
  //optFetch
146
146
  let optFetch = getOptFetch(opt, DFLT)
147
- let showLog = optFetch.showLog
147
+ let useShowLog = optFetch.useShowLog
148
148
 
149
149
  //pageDelayMs, 頁間隨機延遲毫秒
150
150
  let pageDelayMs = get(opt, 'pageDelayMs')
@@ -198,7 +198,7 @@ async function fetchMoneydj(opt = {}) {
198
198
  items = await fetchPage(i)
199
199
  }
200
200
  catch (err) {
201
- if (showLog) {
201
+ if (useShowLog) {
202
202
  console.warn(`[Page ${i}] 抓取失敗,已跳過:${err.message}`)
203
203
  }
204
204
  continue
@@ -238,7 +238,7 @@ export default fetchMoneydj
238
238
  <br class="clear">
239
239
 
240
240
  <footer>
241
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 19:16:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
241
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sun Sep 13 2026 14:29:36 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
242
242
  </footer>
243
243
 
244
244
  <script>prettyPrint();</script>
@@ -166,7 +166,7 @@ async function fetchTargetWithRetry(page, target, cfg) {
166
166
  }
167
167
 
168
168
  let ms = Math.min(cfg.baseDelayMs * attempt, cfg.maxDelayMs)
169
- if (cfg.showLog) {
169
+ if (cfg.useShowLog) {
170
170
  console.warn(`[${target.name}][Retry ${attempt}/${cfg.maxRetries}] ${data.error} — 等待 ${ms / 1000}s 後重試...`)
171
171
  }
172
172
  await delay(ms)
@@ -188,7 +188,7 @@ async function fetchTargetWithRetry(page, target, cfg) {
188
188
  * @param {String} [opt.pageUrl='https://mops.twse.com.tw/mops/#/web/t146sb10'] 輸入MOPS重大訊息頁網址字串,供測試或改指向鏡像時覆寫
189
189
  * @param {String} [opt.apiUrl='https://mops.twse.com.tw/mops/api/t146sb10'] 輸入MOPS查詢API網址字串,供測試或改指向鏡像時覆寫
190
190
  * @param {Integer} [opt.maxRetries=10] 輸入最大重試次數整數,含初始共執行maxRetries+1次,預設10
191
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
191
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
192
192
  * @returns {Promise} 回傳Promise,resolve回傳結果物件{results,hasError},results各筆為{market,marketKind,data,error,timestamp},瀏覽器啟動失敗時reject回傳錯誤物件
193
193
  * @example
194
194
  *
@@ -230,10 +230,10 @@ async function fetchMops(opt = {}) {
230
230
  maxRetries = cint(maxRetries)
231
231
  }
232
232
 
233
- //showLog
234
- let showLog = get(opt, 'showLog')
235
- if (!isbol(showLog)) {
236
- showLog = true
233
+ //useShowLog
234
+ let useShowLog = get(opt, 'useShowLog')
235
+ if (!isbol(useShowLog)) {
236
+ useShowLog = true
237
237
  }
238
238
 
239
239
  //cfg
@@ -241,7 +241,7 @@ async function fetchMops(opt = {}) {
241
241
  maxRetries,
242
242
  baseDelayMs: DEFAULT_BASE_DELAY_MS,
243
243
  maxDelayMs: DEFAULT_MAX_DELAY_MS,
244
- showLog,
244
+ useShowLog,
245
245
  }
246
246
 
247
247
  //targets
@@ -254,7 +254,7 @@ async function fetchMops(opt = {}) {
254
254
  }
255
255
  })
256
256
 
257
- if (showLog) {
257
+ if (useShowLog) {
258
258
  console.log('啟動瀏覽器...')
259
259
  }
260
260
 
@@ -279,7 +279,7 @@ async function fetchMops(opt = {}) {
279
279
  throw new Error(`瀏覽器啟動失敗(已重試 ${maxRetries} 次): ${err.message}`)
280
280
  }
281
281
  let ms = Math.min(DEFAULT_BASE_DELAY_MS * attempt, DEFAULT_MAX_DELAY_MS)
282
- if (showLog) {
282
+ if (useShowLog) {
283
283
  console.warn(`[browser.launch][Retry ${attempt}/${maxRetries}] ${err.message} — 等待 ${ms / 1000}s 後重試...`)
284
284
  }
285
285
  await delay(ms)
@@ -291,7 +291,7 @@ async function fetchMops(opt = {}) {
291
291
  let page = await browser.newPage()
292
292
 
293
293
  //帶重試之頁面導航
294
- if (showLog) {
294
+ if (useShowLog) {
295
295
  console.log('前往 MOPS 重大訊息頁面 (t146sb10)...')
296
296
  }
297
297
  for (let attempt = 1; attempt &lt;= maxRetries + 1; attempt++) {
@@ -305,7 +305,7 @@ async function fetchMops(opt = {}) {
305
305
  throw err
306
306
  }
307
307
  let ms = Math.min(DEFAULT_BASE_DELAY_MS * attempt, DEFAULT_MAX_DELAY_MS)
308
- if (showLog) {
308
+ if (useShowLog) {
309
309
  console.warn(`[page.goto][Retry ${attempt}/${maxRetries}] ${err.message} — 等待 ${ms / 1000}s 後重試...`)
310
310
  }
311
311
  await delay(ms)
@@ -318,7 +318,7 @@ async function fetchMops(opt = {}) {
318
318
  let results = []
319
319
  for (let target of targets) {
320
320
 
321
- if (showLog) {
321
+ if (useShowLog) {
322
322
  console.log(`正在抓取 [${target.name}] 資料...`)
323
323
  }
324
324
 
@@ -335,7 +335,7 @@ async function fetchMops(opt = {}) {
335
335
  await page.waitForTimeout(1000)
336
336
  }
337
337
 
338
- if (showLog) {
338
+ if (useShowLog) {
339
339
  let summary = results.map((r) => {
340
340
  let resultData = get(r, 'data.result', get(r, 'data'))
341
341
  let count = Array.isArray(resultData) ? resultData.length : 0
@@ -372,7 +372,7 @@ export default fetchMops
372
372
  <br class="clear">
373
373
 
374
374
  <footer>
375
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 19:16:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
375
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sun Sep 13 2026 14:29:36 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
376
376
  </footer>
377
377
 
378
378
  <script>prettyPrint();</script>
@@ -145,7 +145,7 @@ async function getXml(rssUrl, method, cfg) {
145
145
  * @param {Integer} [opt.maxRetries=5] 輸入最大重試次數整數,含初始共執行maxRetries+1次,預設5
146
146
  * @param {Integer} [opt.baseDelayMs=3000] 輸入重試之線性退避基礎毫秒整數(僅fetch模式生效),預設3000
147
147
  * @param {Integer} [opt.maxDelayMs=15000] 輸入重試之線性退避上限毫秒整數(僅fetch模式生效),預設15000
148
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示重試訊息布林值,預設true
148
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示重試訊息布林值,預設true
149
149
  * @returns {Promise} 回傳Promise,resolve回傳項目物件陣列,各物件為{url,time,title,description,from},withContent為true時另含content欄,網址無效或抓取失敗時reject回傳錯誤物件
150
150
  * @example
151
151
  *
@@ -245,7 +245,7 @@ export default fetchRSS
245
245
  <br class="clear">
246
246
 
247
247
  <footer>
248
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 19:16:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
248
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sun Sep 13 2026 14:29:36 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
249
249
  </footer>
250
250
 
251
251
  <script>prettyPrint();</script>
@@ -94,7 +94,7 @@ let FALLBACK_DATE = 'time, [class*="date"], [class*="time"]'
94
94
  * @param {Integer} [opt.maxRetries=10] 輸入最大重試次數整數,含初始共執行maxRetries+1次,預設10
95
95
  * @param {Integer} [opt.baseDelayMs=5000] 輸入重試之線性退避基礎毫秒整數,預設5000
96
96
  * @param {Integer} [opt.maxDelayMs=30000] 輸入重試之線性退避上限毫秒整數,預設30000
97
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
97
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
98
98
  * @returns {Promise} 回傳Promise,resolve回傳新聞物件陣列,各物件為{time,title,link},抓取失敗或解析到0筆時reject回傳錯誤物件
99
99
  * @example
100
100
  *
@@ -123,9 +123,9 @@ async function fetchStatementdog(opt = {}) {
123
123
 
124
124
  //optFetch
125
125
  let optFetch = getOptFetch(opt, DFLT)
126
- let showLog = optFetch.showLog
126
+ let useShowLog = optFetch.useShowLog
127
127
 
128
- if (showLog) {
128
+ if (useShowLog) {
129
129
  console.log(`Fetching ${url}...`)
130
130
  }
131
131
 
@@ -144,7 +144,7 @@ async function fetchStatementdog(opt = {}) {
144
144
  let titleSel = usePrimary ? PRIMARY_TITLE : FALLBACK_TITLE
145
145
  let linkSel = usePrimary ? PRIMARY_LINK : FALLBACK_LINK
146
146
  let dateSel = usePrimary ? PRIMARY_DATE : FALLBACK_DATE
147
- if (!usePrimary &amp;&amp; showLog) {
147
+ if (!usePrimary &amp;&amp; useShowLog) {
148
148
  console.warn('主要 CSS selector 未匹配,嘗試 fallback selector...')
149
149
  }
150
150
 
@@ -172,7 +172,7 @@ async function fetchStatementdog(opt = {}) {
172
172
  newsItems.push({ time, title, link })
173
173
  })
174
174
 
175
- if (showLog) {
175
+ if (useShowLog) {
176
176
  console.log(`Extracted News Items: ${newsItems.length}`)
177
177
  }
178
178
 
@@ -200,7 +200,7 @@ export default fetchStatementdog
200
200
  <br class="clear">
201
201
 
202
202
  <footer>
203
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 19:16:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
203
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sun Sep 13 2026 14:29:36 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
204
204
  </footer>
205
205
 
206
206
  <script>prettyPrint();</script>
@@ -191,7 +191,7 @@ function parseNum(str) {
191
191
  async function fetchFuturesData(dateSlash, cfg) {
192
192
 
193
193
  let url = `${cfg.baseUrl}/cht/3/futDataDown?down_type=1&amp;queryStartDate=${dateSlash}&amp;queryEndDate=${dateSlash}&amp;commodity_id=TX`
194
- if (cfg.showLog) {
194
+ if (cfg.useShowLog) {
195
195
  console.log(`Fetching futures data: ${url}`)
196
196
  }
197
197
 
@@ -248,7 +248,7 @@ async function fetchFuturesData(dateSlash, cfg) {
248
248
  result.afterHoursVolume = parseNum(afterHoursRow['成交量'])
249
249
  }
250
250
 
251
- if (cfg.showLog) {
251
+ if (cfg.useShowLog) {
252
252
  console.log(` 台指期近月 (${nearMonth}): 開${result.open} 高${result.high} 低${result.low} 收${result.close} 結算${result.settlement} 量${result.volume}`)
253
253
  if (result.afterHoursClose !== null) {
254
254
  console.log(` 盤後: 收${result.afterHoursClose} 結算${result.afterHoursSettlement} 量${result.afterHoursVolume}`)
@@ -269,7 +269,7 @@ async function fetchFuturesData(dateSlash, cfg) {
269
269
  async function fetchInstitutionalData(dateSlash, cfg) {
270
270
 
271
271
  let url = `${cfg.baseUrl}/cht/3/futContractsDateDown?queryStartDate=${dateSlash}&amp;queryEndDate=${dateSlash}&amp;commodityId=TXF`
272
- if (cfg.showLog) {
272
+ if (cfg.useShowLog) {
273
273
  console.log(`Fetching institutional data: ${url}`)
274
274
  }
275
275
 
@@ -300,7 +300,7 @@ async function fetchInstitutionalData(dateSlash, cfg) {
300
300
  tradingNet: parseNum(row['多空交易口數淨額']),
301
301
  }
302
302
 
303
- if (cfg.showLog) {
303
+ if (cfg.useShowLog) {
304
304
  console.log(` ${identity}: 未平倉淨額 ${result[key].netContracts} 口`)
305
305
  }
306
306
 
@@ -326,7 +326,7 @@ async function fetchInstitutionalData(dateSlash, cfg) {
326
326
  async function fetchPCRatio(dateSlash, cfg) {
327
327
 
328
328
  let url = `${cfg.baseUrl}/cht/3/pcRatioDown?queryStartDate=${dateSlash}&amp;queryEndDate=${dateSlash}`
329
- if (cfg.showLog) {
329
+ if (cfg.useShowLog) {
330
330
  console.log(`Fetching P/C ratio: ${url}`)
331
331
  }
332
332
 
@@ -346,7 +346,7 @@ async function fetchPCRatio(dateSlash, cfg) {
346
346
  openInterestRatio: parseNum(row['買賣權未平倉量比率%']),
347
347
  }
348
348
 
349
- if (cfg.showLog) {
349
+ if (cfg.useShowLog) {
350
350
  console.log(` Put ${result.putVolume} / Call ${result.callVolume} = ${result.ratio}%`)
351
351
  }
352
352
 
@@ -368,7 +368,7 @@ async function fetchPCRatio(dateSlash, cfg) {
368
368
  * @param {Integer} [opt.baseDelayMs=5000] 輸入重試之線性退避基礎毫秒整數,預設5000
369
369
  * @param {Integer} [opt.maxDelayMs=30000] 輸入重試之線性退避上限毫秒整數,預設30000
370
370
  * @param {Integer} [opt.interRequestDelayMs=1000] 輸入三支CSV之間隔毫秒整數,預設1000
371
- * @param {Boolean} [opt.showLog=true] 輸入是否顯示過程訊息布林值,預設true
371
+ * @param {Boolean} [opt.useShowLog=true] 輸入是否顯示過程訊息布林值,預設true
372
372
  * @returns {Promise} 回傳Promise,resolve回傳結果物件{date,futures,institutional,pcRatio,errors},日期無效或三支資料全失敗時reject回傳錯誤物件
373
373
  * @example
374
374
  *
@@ -406,8 +406,8 @@ async function fetchTaifex(dateStr, opt = {}) {
406
406
 
407
407
  //cfg
408
408
  let optFetch = getOptFetch(opt, DFLT)
409
- let showLog = optFetch.showLog
410
- let cfg = { baseUrl, showLog, optFetch }
409
+ let useShowLog = optFetch.useShowLog
410
+ let cfg = { baseUrl, useShowLog, optFetch }
411
411
 
412
412
  //interRequestDelayMs
413
413
  let interRequestDelayMs = get(opt, 'interRequestDelayMs')
@@ -420,7 +420,7 @@ async function fetchTaifex(dateStr, opt = {}) {
420
420
 
421
421
  //dateSlash
422
422
  let dateSlash = `${dateStr.substring(0, 4)}/${dateStr.substring(4, 6)}/${dateStr.substring(6, 8)}`
423
- if (showLog) {
423
+ if (useShowLog) {
424
424
  console.log(`Fetching TAIFEX data for ${dateStr} (${dateSlash})`)
425
425
  }
426
426
 
@@ -434,7 +434,7 @@ async function fetchTaifex(dateStr, opt = {}) {
434
434
  }
435
435
  catch (err) {
436
436
  let msg = `台指期行情: ${get(err, 'message', err)}`
437
- if (showLog) {
437
+ if (useShowLog) {
438
438
  console.error(msg)
439
439
  }
440
440
  errors.push(msg)
@@ -447,7 +447,7 @@ async function fetchTaifex(dateStr, opt = {}) {
447
447
  }
448
448
  catch (err) {
449
449
  let msg = `三大法人: ${get(err, 'message', err)}`
450
- if (showLog) {
450
+ if (useShowLog) {
451
451
  console.error(msg)
452
452
  }
453
453
  errors.push(msg)
@@ -460,7 +460,7 @@ async function fetchTaifex(dateStr, opt = {}) {
460
460
  }
461
461
  catch (err) {
462
462
  let msg = `Put/Call Ratio: ${get(err, 'message', err)}`
463
- if (showLog) {
463
+ if (useShowLog) {
464
464
  console.error(msg)
465
465
  }
466
466
  errors.push(msg)
@@ -500,7 +500,7 @@ export default fetchTaifex
500
500
  <br class="clear">
501
501
 
502
502
  <footer>
503
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 19:16:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
503
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sun Sep 13 2026 14:29:36 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
504
504
  </footer>
505
505
 
506
506
  <script>prettyPrint();</script>