How to get html with source code using getPageSource (was Cómo obtener html con código fuente usando getPageSource)

buenas noches Ejecuto una consulta en una página web, luego obtengo la URL del resultado. Si hago clic derecho en ver fuente html, puedo ver el código html generado por JS

WebUI.navigateToUrl(‘https://…’)
WebDriver driver = DriverFactory.getWebDriver()
def myHTML = driver.getPageSource()
println(myHTML)

pero en lugar del html me aparece el que inicia con

</script></div><div

¿que puedo hacer?


good night I run a query on a web page, then I get the URL of the result.If I right click on view html font, I can see the html code generated by JS

WebUI.navigateToUrl(‘https://…’)
WebDriver driver = DriverFactory.getWebDriver()
def myHTML = driver.getPageSource()
println(myHTML)

but instead of the html I get the one that starts with

</script></div><div

What can I do?

(Edit by @Russ_Thomas)

Hello,

use english please.

If I understood your question correctly…

getPageSource attempts to retrieve the HTML as it was supplied by the server when the page was first visited. If the page then generates new HTML from JavaScript, it will not be part of the original HTML since it was not supplied by the server.

To view current, rendered HTML, use the DevTools Inspector:

I run a query in one web page, then I get result url. If I right click see html source, I can see the html code generated by JS. If I simply use urllib, python cannot get the JS code.

I run a query in one web page, then I get result url. If I right click see html source, I can see the html code generated by JS. If I simply use urllib, python cannot get the JS code.