longvh211 / Chromium-Automation-with-CDP-for-VBA

A method to directly automate Chromium-based web browsers, such as Chrome, Edge, and Firefox, using VBA for Office applications by following the Chrome DevTools Protocol framework.
MIT License
45 stars 6 forks source link

InnerHTML #3

Closed chrisdaniels closed 2 years ago

chrisdaniels commented 2 years ago

Hi again

Are you are to assist with this command at all please?

It works in the Chrome console as document.Evaluate("//body", document.body, null, 9, null).singleNodeValue.innerHTML but in VBA it returns null - i've tried all kinds of variations.

VBA: Body = tab2.jsEval("document.Evaluate(""//body"", document.body, null, 9, null).singleNodeValue.innerHTML")

I need to pass the innerHTML to Excel in order to extract several tables of data.

longvh211 commented 2 years ago

Hi Chris,

Maybe try:

tab2.jsEval("x = document.Evaluate(""//body"", document.body, null, 9, null).singleNodeValue.innerHTML") Body = tab2.jsEval("x")

chrisdaniels commented 2 years ago

Thank you

I've got it working - it was because document.evaluate is case sensitive!