0

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 actual 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

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Trinitrotoluene
  • 1,388
  • 5
  • 20
  • 39

1 Answers1

2

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
Community
  • 1
  • 1
thirtydot
  • 224,678
  • 48
  • 389
  • 349
  • This is excellent - thank you. I looked into parsing via the tags but it got a bit difficult as they are in a table. Thanks again – Trinitrotoluene Jan 28 '11 at 01:56