VBScript-将网页的源代码分配给变量

时间:2018-11-20 16:51:17

标签: vbscript

我正在尝试编写一个VBScript,该外观看起来可以根据该网站的内容来浏览该网站。为此,我需要能够将每个网页的源代码分配给一个字符串变量,并使脚本在该字符串中查找某些单词。

我认为这是一个解决方案:

Function GetSourceCode(url)
     Set objHttp = CreateObject("Microsoft.XMLHTTP")
     bGetAsAsync = False

     objHttp.open "GET", url, bGetAsAsync
     objHttp.send

     If objHttp.status <> 200 Then
         wscript.Echo "unexpected status = " & objHttp.status & vbCrLf & objHttp.statusText
         wscript.Quit
     End If

     'MsgBox objHttp.responseText

     GetSourceCode = objHttp.responseText
End Function

但这不起作用。我在其他地方看到过,AutoIT可以做到这一点,但是我无法根据每个安全策略使用AutoIT。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

string str = "<input type=\"hidden\" id=\"taken\" value=\"BoboBobo\">\n<input type=\"hidden\" id=\"took\" value=\"BaboboBe\""更改为Microsoft.XMLHTTP

Msxml2.ServerXMLHTTP

enter image description here