开发者

Need to pull out a link from a website using VBscript

I have got as far as getting the HTML response into a variable and now I am stuck:

Link: http://www.avg.com/gb-en/31.prd-avb

In an ideal world I would be able to get the first and second link for x86 and x64. All I need to get is the a开发者_Go百科ctual location of the exe into a variable: IE:

download.avg.com/filedir/inst/avg_ipw_x86_all_2011_1204a3402.exe

Can anyone point me in the right direction?

Thanks in advance for any help provided


This works, but it's far from a stellar technique, because I'm parsing HTML with regex.

However, I'm not aware of an easier method to accomplish this in Classic ASP, and this is a simple task.

<%

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

%>

Gives output like this:

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜