vault backup: 2026-11-06 20:25:47
This commit is contained in:
1 parent
a8080408a7
commit
f7d1bff65f
3 files changed
+142
No files matched your search
@@ -0,0 +1,29 @@
|
||||
// 检查百家号页面状态:登录态、页面文字、可用的数据入口
|
||||
import { connect, attachPage, evaluate, saveJson } from './lib.mjs';
|
||||
|
||||
const cdp = await connect();
|
||||
const hit = await attachPage(cdp, 'baijiahao.baidu.com');
|
||||
if (!hit) { console.log('NO_BAIJIAHAO_TAB'); process.exit(1); }
|
||||
|
||||
const { sessionId } = hit;
|
||||
await cdp.send('Runtime.enable', {}, sessionId).catch(() => {});
|
||||
|
||||
const info = await evaluate(cdp, sessionId, `(() => {
|
||||
const t = document.body ? document.body.innerText : '';
|
||||
return {
|
||||
url: location.href,
|
||||
title: document.title,
|
||||
textLen: t.length,
|
||||
textSample: t.slice(0, 3000),
|
||||
links: Array.from(document.querySelectorAll('a')).slice(0, 60).map(a => ({
|
||||
text: (a.innerText || '').trim().slice(0, 40),
|
||||
href: a.href
|
||||
})).filter(x => x.href)
|
||||
};
|
||||
})()`);
|
||||
|
||||
saveJson('out/page-info.json', info);
|
||||
console.log('URL=' + info.url.replace(/[^\x20-\x7E]/g, '?'));
|
||||
console.log('TEXTLEN=' + info.textLen);
|
||||
console.log('SAVED out/page-info.json');
|
||||
process.exit(0);
|
||||
Reference in new issue
Block a user