koishi-plugin-bns-blacklist 1.0.7 → 1.0.8
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.
- package/lib/index.js +11 -7
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -227,15 +227,16 @@ async function scrapeSheet(page, url, logger) {
|
|
|
227
227
|
const text = item.text || item.body;
|
|
228
228
|
if (logger)
|
|
229
229
|
logger.info(` ${item.endpoint} -> status=${item.status}, len=${text?.length}`);
|
|
230
|
+
if (!text || text.length < 10)
|
|
231
|
+
continue;
|
|
232
|
+
// Log raw first 300 chars regardless
|
|
233
|
+
if (logger)
|
|
234
|
+
logger.info(` Raw sample: ${text.substring(0, 300)}`);
|
|
230
235
|
try {
|
|
231
236
|
const json = JSON.parse(text);
|
|
232
|
-
|
|
233
|
-
if (logger
|
|
234
|
-
const keys = Object.keys(json);
|
|
237
|
+
const keys = Object.keys(json);
|
|
238
|
+
if (logger)
|
|
235
239
|
logger.info(` JSON keys: [${keys.join(', ')}]`);
|
|
236
|
-
// Log first 500 chars
|
|
237
|
-
logger.info(` JSON sample: ${text.substring(0, 500)}`);
|
|
238
|
-
}
|
|
239
240
|
const rows = extractRowsFromJson(json);
|
|
240
241
|
if (rows.length > 0) {
|
|
241
242
|
if (logger)
|
|
@@ -243,7 +244,10 @@ async function scrapeSheet(page, url, logger) {
|
|
|
243
244
|
return parseSheetData(rows);
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
|
-
catch (
|
|
247
|
+
catch (e) {
|
|
248
|
+
if (logger)
|
|
249
|
+
logger.info(` JSON parse failed: ${e.message}`);
|
|
250
|
+
}
|
|
247
251
|
}
|
|
248
252
|
// Strategy 2: Dump page text and try to parse
|
|
249
253
|
const pageText = await page.evaluate(() => document.body.innerText);
|