51 lines
1.9 KiB
JavaScript
51 lines
1.9 KiB
JavaScript
import auth from '../tools/siemens-auth.js';
|
|
|
|
const browser = await auth.getBrowser();
|
|
const page = await browser.newPage();
|
|
await auth.loadCookies(page);
|
|
|
|
// Navigate to annotated.html and find Part class
|
|
await page.goto('https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/annotated.html', { waitUntil: 'networkidle2' });
|
|
await new Promise(r => setTimeout(r, 3000));
|
|
|
|
// Find Part class links
|
|
const partLinks = await page.evaluate(() => {
|
|
const links = Array.from(document.querySelectorAll('a.el'));
|
|
return links
|
|
.filter(a => a.innerText && (a.innerText === 'Part' || a.innerText === 'NXOpen::Part'))
|
|
.map(a => ({ text: a.innerText.trim(), href: a.href.split('/').pop() }));
|
|
});
|
|
|
|
console.log('Part links found:', partLinks);
|
|
|
|
// Also search for BasePart
|
|
const basePartLinks = await page.evaluate(() => {
|
|
const links = Array.from(document.querySelectorAll('a.el'));
|
|
return links
|
|
.filter(a => a.innerText && a.innerText.includes('BasePart'))
|
|
.map(a => ({ text: a.innerText.trim(), href: a.href.split('/').pop() }))
|
|
.slice(0, 5);
|
|
});
|
|
|
|
console.log('BasePart links:', basePartLinks);
|
|
|
|
// Navigate to Part if found
|
|
if (partLinks.length > 0) {
|
|
const partUrl = 'https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/' + partLinks[0].href;
|
|
console.log('\nNavigating to:', partUrl);
|
|
await page.goto(partUrl, { waitUntil: 'networkidle2' });
|
|
await new Promise(r => setTimeout(r, 3000));
|
|
|
|
const content = await page.evaluate(() => ({
|
|
title: document.title,
|
|
hasError: document.body.innerText.includes('Access Denied'),
|
|
preview: document.body.innerText.substring(0, 2000)
|
|
}));
|
|
|
|
console.log('Title:', content.title);
|
|
console.log('Has error:', content.hasError);
|
|
console.log('Content:', content.preview);
|
|
}
|
|
|
|
await auth.closeBrowser();
|