您可以采用如下方案来从文本内容
VALUEA,
VALUEB,
VALUEC,和
VALUED:
const example = await page.evaluate( () =>{ const page = document.createElement( 'html' ); const page_content = document.body.textContent; page.innerHTML = page_content; return { 'VALUEA' : Array.from( page.getElementsByTagName( 'VALUEA' ), e => e.textContent ), 'VALUEB' : Array.from( page.getElementsByTagName( 'VALUEB' ), e => e.textContent ), 'VALUEC' : Array.from( page.getElementsByTagName( 'VALUEC' ), e => e.textContent ), 'VALUED' : Array.from( page.getElementsByTagName( 'VALUED' ), e => e.textContent ) };});console.log( example.VALUEA[0] ); // Company Aconsole.log( example.VALUEA[1] ); // Company Bconsole.log( example.VALUEB[0] ); // INCconsole.log( example.VALUEB[1] ); // LTDconsole.log( example.VALUEC[0] ); // 123console.log( example.VALUEC[1] ); // 567console.log( example.VALUED[0] ); // ABconsole.log( example.VALUED[1] ); // ST
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)