我已经将HTML响应变为变量,现在我陷入困境:
链接:http://www.avg.com/gb-en/31.prd-avb
在理想的世界中,我将能够获得x86和x64的第一个和第二个链接。我需要得到的是exe到变量的实际位置:IE:
download.avg.com/filedir/inst/avg_ipw_x86_all_2011_1204a3402.exe
有人能指出我正确的方向吗?
提前感谢您提供的任何帮助
答案 0 :(得分:2)
这很有效,但它远非一流的技术,因为我是parsing HTML with regex。
但是,我不知道在Classic ASP中实现此功能的更简单方法,这是一项简单的任务。
<%
url = "http://www.avg.com/gb-en/31.prd-avb"
Dim http
Set http = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
http.SetTimeouts 20000, 20000, 20000, 10000
http.Open "GET", url, False
http.Send
If http.WaitForResponse(5) Then
responseText = http.ResponseText
End If
Set http = Nothing
'Response.Write(Server.HtmlEncode(responseText))
Set re = New RegExp
re.IgnoreCase = True
re.Global = True
re.Pattern = "<a href=""(http://download\.avg\.com/filedir/inst/.*?)"""
Set matches = re.Execute(responseText)
If matches.Count > 0 Then
For Each match In matches
Response.Write(match.SubMatches(0) & "<br />")
Next
Else
Response.Write("No matches.")
End If
%>
给出如下输出:
http://download.avg.com/filedir/inst/avg_ipw_x86_all_2011_1204a3402.exe
http://download.avg.com/filedir/inst/avg_ipw_x64_all_2011_1204a3402.exe
http://download.avg.com/filedir/inst/avg_msw_x86_all_2011_1204a3402.exe
http://download.avg.com/filedir/inst/avg_msw_x64_all_2011_1204a3402.exe
http://download.avg.com/filedir/inst/avg_rad_x86_all_2011_1154.exe
http://download.avg.com/filedir/inst/avg_rad_x64_all_2011_1154.exe