在Powershell中获取JavaScript结果 [英] Get JavaScript result in Powershell

查看:63
本文介绍了在Powershell中获取JavaScript结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CSHTML文件,其中包含一个块< script type ="text/javascript"></script> .

I have a CSHTML file which has a block <script type="text/javascript"></script> inside.

它将显示用户名:

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>";

现在我想在Powershell中获得此结果,有人知道该怎么做吗?

Now I want to get this result in Powershell, anyone knows how to do it?

我尝试使用 Invoke-RestMethod Invoke-WebRequest ,但是它总是返回源HTML代码,而不返回结果.

I tried with Invoke-RestMethod and Invoke-WebRequest, but it always returns the source code HTML and not the result.

推荐答案

您可以尝试自动使用Internet Explorer COM对象.

you could try to automate with 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} 

这篇关于在Powershell中获取JavaScript结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆