How can I apply javascript to an html stored in string/stringbuffer ?
I am extracting the html of a webpage using Java
URL url = new URL("example.com");
InputStream is = url.openStream();
int ptr = 0;
StringBuffer buffer = new StringBuffer();
while ((ptr = is.read()) != -1) {
buffer.append((char)ptr);
}
System.out.println(buffer);
and I want to apply javascript to the buffer to get innerHTML of some tag using document.getElementById().
My purpose is to get the innerHTML of some tag inside a webpage without opening it on browser. Am I using the correct way ? Is there some other way to do so ?