Jump to content

Recommended Posts

Posted (edited)

im trying to write a script that automates the download of an update. problem is that the filename changes and on rare occassion the link may change (so id want to error out or give the script runner the option of clicking on new link)

planning on using inetget.

http://about.bloomberg.com/contact_softwaresupport_upgr_html.html

Edited by gcue
Posted

actually they have an index site!

ill look at the file dates and find the newest file with string upgr*

hmm never worked with html reading but ill try it out!

Posted

You could always just parse the source code to find the link.

#include <INet.au3>

; Get Software Update page source
$sHTML = _INetGetSource("http://about.bloomberg.com/contact_softwaresupport_upgr_html.html")
If @error Then
    ConsoleWrite("Error downloading source page" & @LF)
    Exit
EndIf

;Parse Bloomberg Application paragraph section
$aResult = StringRegExp($sHTML, "(?i)(?s)(?U:<p><strong>Bloomberg Application.+</p>)", 3)
If @error Then
    ConsoleWrite("Error parsing Bloomberg Application paragraph" & @LF)
    Exit
EndIf
$sBAParagraph = $aResult[0]

;Parse version information
$aResult = StringRegExp($sBAParagraph, "(?i)\((.+)\)", 3)
If @error Then
    ConsoleWrite("Error parsing version information" & @LF)
    Exit
EndIf
$sVersionInfo = $aResult[0]

;Parse download hyperlink
$aResult = StringRegExp($sBAParagraph, '(?i)(?U)<a.+"(.+)"', 3)
If @error Then
    ConsoleWrite("Error parsing download hyperlink" & @LF)
    Exit
EndIf
$sDLLink = $aResult[0]

;Display Info
$iReturn = MsgBox(0x24, "Available Download: Bloomberg", StringFormat("Application Name:\tBloomberg Application\r\nVersion Info:\t%s\r\nDownload Link:\t%s\r\n\r\nDownload the update?", $sVersionInfo, $sDLLink))

;Download File
If $iReturn = 6 Then
    ProgressOn("Bloomberg Application update", "Download in progress...")
    $iSize = InetGetSize($sDLLink)
    $iReturn = InetGet($sDLLink, @DesktopDir & "\BloombergUpdate.exe")
    If $iReturn = 0 Then
        MsgBox(4096, "Error", "Download failed!")
        Exit
    EndIf
    While @InetGetActive = 1
        ProgressSet(@InetGetBytesRead / $iSize * 100)
        Sleep(100)
    WEnd
    ProgressOff()
EndIf
Posted

awesome!!!!!! many thanks

very interesting way of doing it..

hehe alot cleaner than what i was gonna do..

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...