I am currently working on a C-based application that accesses web pages to retrieve HTML data, including JavaScript code. In order to execute the JavaScript code, I have integrated V8 (the JavaScript engine used in Chrome) into my C code.
I am seeking advice on the best approach to follow for executing JavaScript code within the HTML data. One possible logic is:
Load and execute all downloaded JavaScript files using V8. This will load the JavaScript into memory, but may not provide any useful output.
When encountering HTML data with a script tag containing JavaScript code, execute the JavaScript within the script tag.
Is this approach correct, or am I missing something? If you have a better suggestion, please share your insights.
EDIT1
My main question revolves around determining the most effective logic when parsing through HTML data and executing JavaScript contained within it.
EDIT2
For example, tools like JMeter are able to receive HTML and JavaScript data and execute the JavaScript code, typically done in Java. However, I need to achieve the same functionality in C by leveraging V8 integration. What I am trying to figure out now is the optimal method for scanning HTML data and executing JavaScript code within it.