koishi-plugin-bns-blacklist 1.0.6 → 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 +16 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -224,18 +224,30 @@ async function scrapeSheet(page, url, logger) {
|
|
|
224
224
|
if (logger)
|
|
225
225
|
logger.info(`API endpoints tried: ${apiData.length} responded`);
|
|
226
226
|
for (const item of apiData) {
|
|
227
|
+
const text = item.text || item.body;
|
|
227
228
|
if (logger)
|
|
228
|
-
logger.info(` ${item.endpoint} -> status=${item.status}, len=${
|
|
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)}`);
|
|
229
235
|
try {
|
|
230
|
-
const json = JSON.parse(
|
|
236
|
+
const json = JSON.parse(text);
|
|
237
|
+
const keys = Object.keys(json);
|
|
238
|
+
if (logger)
|
|
239
|
+
logger.info(` JSON keys: [${keys.join(', ')}]`);
|
|
231
240
|
const rows = extractRowsFromJson(json);
|
|
232
241
|
if (rows.length > 0) {
|
|
233
242
|
if (logger)
|
|
234
|
-
logger.info(`Found data: ${rows.length} rows
|
|
243
|
+
logger.info(`Found data: ${rows.length} rows`);
|
|
235
244
|
return parseSheetData(rows);
|
|
236
245
|
}
|
|
237
246
|
}
|
|
238
|
-
catch (
|
|
247
|
+
catch (e) {
|
|
248
|
+
if (logger)
|
|
249
|
+
logger.info(` JSON parse failed: ${e.message}`);
|
|
250
|
+
}
|
|
239
251
|
}
|
|
240
252
|
// Strategy 2: Dump page text and try to parse
|
|
241
253
|
const pageText = await page.evaluate(() => document.body.innerText);
|