Get JavaScript result in Powershell
I have a CSHTML file that has a block inside it <script type="text/javascript"></script>
.
It will show usernames:
for (var i = 0; i < result2.Users.length; i++) {
var item = "<li style='width:100%;'>" + result2.Users[i].TchatEngineId.toString() + " | " + result2.Users[i].Pseudo + "</li>";
Now I want to get this result in Powershell, does anyone know how to do this?
I've tried with Invoke-RestMethod
and Invoke-WebRequest
, but it always returns the HTML source, not the result.
+3
source to share
2 answers
you can try to automate using the Internet Explorer COM object.
function wait4IE($ie=$global:ie){
while ($ie.busy -or $ie.readystate -lt 4){start-sleep -milliseconds 200}
}
$global:ie=new-object -com "internetexplorer.application"
$ie.visible=$true
$ie.navigate("http://domain.com/file.html")
wait4IE
$names=$ie.Document.getElementsByTagName("li")
$names|%{$_.innerText}
+1
source to share