You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

76 lines
3.6 KiB

// v3:进入 Axure 查看器,抓 data.js 的真实 URL 模式
import { chromium } from 'file:///C:/Users/Administrator/AppData/Roaming/npm/node_modules/@star_work/lanhu-mcp/node_modules/playwright/index.mjs';
import fs from 'node:fs';
const TID = 'b013dded-642f-4899-b829-daa5c093fdf0';
const PID = 'e528bb49-1eea-4d76-b7e0-4055bc7c1b70';
const DOC_ID = 'bade4454-52aa-44db-8ba2-dec594732ecb';
const DOC_URL = `https://lanhuapp.com/web/#/item/project/product?tid=${TID}&pid=${PID}&image_id=${DOC_ID}&docId=${DOC_ID}&docType=axure&versionId=c461813e-2c49-4bcc-8602-babcaf14c3bb`;
const raw = fs.readFileSync('e:/code/crm-backend-matt/.scratch/opportunity-e2e/原型及蓝湖cookie.txt', 'utf8');
const cookieLine = raw.split('\n').find(l => l.startsWith('Cookie:') || l.startsWith('Cookie:')) || raw.split('\n')[1];
const cookieStr = cookieLine.replace(/^Cookie[::]\s*/, '').trim();
const pairs = cookieStr.split(';').map(s => s.trim()).filter(Boolean).map(s => {
const i = s.indexOf('='); return { name: s.slice(0, i), value: s.slice(i + 1) };
});
const browser = await chromium.launch({ headless: false });
const context = await browser.newContext({
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
viewport: { width: 1720, height: 1080 },
});
await context.addCookies(pairs.map(p => ({ name: p.name, value: p.value, domain: '.lanhuapp.com', path: '/' })));
const page = await context.newPage();
const log = [];
page.on('response', async (resp) => {
const url = resp.url();
if (/hm\.baidu|arms-retcode|aliyuncs\.com\/error|acjs/.test(url)) return;
const entry = { url: url.slice(0, 600), status: resp.status(), method: resp.request().method() };
try {
const ct = resp.headers()['content-type'] || '';
entry.ct = ct.split(';')[0];
if (ct.includes('json') || /\.js($|\?)/.test(url)) {
const body = await resp.text();
entry.body = body.length > 3000 ? body.slice(0, 3000) + '...<trunc>' : body;
}
} catch { }
log.push(entry);
});
console.log('[1] goto doc list ...');
await page.goto(DOC_URL, { waitUntil: 'domcontentloaded', timeout: 60000 });
await page.waitForTimeout(10000);
console.log('[2] click target doc ...');
const el = page.locator('text=【原型】itc信息化业务中台web端').first();
await el.click({ timeout: 15000 }).catch(e => console.log(' click failed:', e.message.split('\n')[0]));
await page.waitForTimeout(25000);
// 也许进入了 axure viewer;dump 当前 URL 与文本
console.log('[3] current url:', page.url());
const txt = await page.evaluate(() => document.body.innerText).catch(() => '(failed)');
// 若 viewer 里有左侧页面树,尝试点击「团队成员」页 —— A3-1-1-1-8
try {
const teamTab = page.locator('text=团队成员').first();
if (await teamTab.count() > 0) {
console.log('[4] clicking 团队成员 page in tree ...');
await teamTab.click({ timeout: 8000 });
await page.waitForTimeout(12000);
}
} catch (e) { console.log(' tree click skip:', e.message.split('\n')[0]); }
const txt2 = await page.evaluate(() => document.body.innerText).catch(() => '(failed)');
fs.writeFileSync('e:/code/crm-backend-matt/.scratch/lanhu-latest/network-log-v3.json', JSON.stringify(log, null, 2), 'utf8');
fs.writeFileSync('e:/code/crm-backend-matt/.scratch/lanhu-latest/page-dump-v3.txt', txt2, 'utf8');
console.log('captured:', log.length);
console.log('=== axure-file / oss / data.js urls ===');
for (const e of log) {
if (/axure|data\.js|\.html|oss/.test(e.url)) console.log(' ', e.status, e.method, e.url.slice(0, 200));
}
console.log('=== page text head ===');
console.log(txt2.slice(0, 500));
await browser.close();