大家好我需要帮助。我的html中有一行网页:
<h3 class="entity-title"><a name="33333" class="link" href="/xy/xy-33333">some text</a></h3>
我想要打开网页的VBScript并找到这一行并复制&#34; / xy / xy-33333&#34;一些字符串变量。 name,href和一些文本总是随机的
我有这个部分(将所有HTML保存到file.txt)
Dim oXMLHTTP
Dim oStream
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
oXMLHTTP.Open "GET", "http://www.yyy.com", False
oXMLHTTP.Send
If oXMLHTTP.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write oXMLHTTP.responseBody
oStream.SaveToFile "c:\te\file.txt"
oStream.Close
End If
答案 0 :(得分:1)
尝试这样的事情:
...
If oXMLHTTP.Status = 200 Then
Set html = CreateObject("HTMLfile")
html.write oXMLHTTP.responseText
For Each h3 In html.getElementsByTagName("h3")
If h3.getAttribute("class") = "entity-title" Then
For Each a In h3.getElementsByTagName("a")
WScript.Echo a.href
Next
End If
Next
End If