HTA从网页获取数据到hta文本框

HTA to get data from webpage to hta textbox

我想使用 Hta 从网页到 hta 文本框的数据。下面是我正在尝试创建的代码,但我不知道如何从网页调用数据到 hta 文本框。

<html>
<head>
<title>My HTML Application</title>
<script language="vbscript">
  urls=("https://www.99acres.com/shri-laxmi-celebration-residency-sector-2b-vasundhara-ghaziabad-npxid-r63907?src=NPSRP&sid=UiB8IFFTIHwgUyB8IzEjICB8IG5vaWRhIzUjIHwgQ1AxMiB8IFkgIzE4I3wgIHwgMTIgfCMzIyAgfCA3ICM1I3wgIHwgMjMgfCM0MyMgIHw=")
    Sub RunLoop()
        window.navigate urls  
    End Sub
</script>
</head>
<body>
<input type="button" value="Click" onclick="RunLoop">
Possession:
<input type="text" name="Possession" Value="">
Configurations:
<input type="text" name="Configurations" Value="">
New Booking Base Price:
<input type="text" name="New Booking Base Price" Value="">
</body>
</html>

我需要的网页数据。

我在 hta 中需要的输出。

使用window.ActiveXObject("Microsoft.XMLHTTP"),我们得到整个网页并将其分配给invisible/hidden div(为简单起见)。请注意,由于网页自身的全局样式,这可能会导致不需要的样式。更好的方法是在单独的 IE 上打开网页。

HTA 的默认引擎是 IE7,因此我们需要插入 meta http-equiv="x-ua-compatible" content="ie=9" 以支持 getElementsByClassName 功能,因为我们要从 99acres.com 获取的数据已被 class 引用。

将下面的代码复制到记事本并保存为xxx.hta:

<html>
<head>
<meta http-equiv="x-ua-compatible" content="ie=9">
<title>My HTML Application</title>
<script language="javascript">

var url= "https://www.99acres.com/shri-laxmi-celebration-residency-sector-2b-vasundhara-ghaziabad-npxid-r63907?src=NPSRP&sid=UiB8IFFTIHwgUyB8IzEjICB8IG5vaWRhIzUjIHwgQ1AxMiB8IFkgIzE4I3wgIHwgMTIgfCMzIyAgfCA3ICM1I3wgIHwgMjMgfCM0MyMgIHw=";
var xmlHttp = new window.ActiveXObject("Microsoft.XMLHTTP");

function httpGet(theUrl){
    xmlHttp.open( "GET", theUrl, false );
    xmlHttp.send( null );
    return xmlHttp.responseText;
}

function RunLoop() {
    var data = httpGet(url);
    document.getElementById("tempdiv").innerHTML = data;
    document.getElementsByName("Possession")[0].value = document.getElementsByClassName("factVal1")[0].innerHTML;
    document.getElementsByName("Configurations")[0].value = document.getElementsByClassName("factVal1")[1].innerHTML;
    document.getElementsByName("New Booking Base Price")[0].value = document.getElementsByClassName("factValsecond")[0].innerHTML;
}

</script>

</head>
<body>
<input type="button" value="Click" onclick="javascript:RunLoop();">
Possession:
<input type="text" name="Possession" Value="">
Configurations:
<input type="text" name="Configurations" Value="">
New Booking Base Price:
<input type="text" name="New Booking Base Price" Value="">

<div id="tempdiv" style="display:none;visibility:hidden;height:0px">
</div>

</body>
</html>