access a web site and compare version numbers

Discussion in 'Software' started by red death68, Sep 6, 2011.

  1. red death68

    red death68 Command Sergeant Major

    ok what i wanna do is make a script or something to update installers i have.

    i want it to access the site for the program(or major geeks) compare version numbers and if the version number is greater download and replace the previous installer

    is there a way to do this with vbs,javascript,or regular java?

    (im currently in my class learning java right this moment but we still on loops)
     
  2. GermanOne

    GermanOne Guest

    Depends on where to find the version number. I'm pretty sure you have no access to read meta data of a file which is saved on a web server. You could download the source text of the web site and try to find the version# by using Regular Expressions or someting similar. But IMHO it's a feasible method but not a safe method. You have to write a separate algorithm for each web site, but it will fail if they change the layout.

    It's no problem to get it from a local file via VBS or JS (I'm not familiar with Java, but it's probably not a big deal in Java).
     
  3. red death68

    red death68 Command Sergeant Major

    ok thats what i was afraid of oh well its the manual way for now

    maybe when my java class is done i can figure it out
     
  4. Colemanguy

    Colemanguy MajorGeek

    This is a very bad idea btw, with out the site owners permission, because your if your app isn't written properly, it will be constantly grabbing data from what ever site your version checking on, increasing there bandwidth usage. Its best to check with a site owner or even some developers offer automated methods to check if they have new releases of files. Just something to keep in mind.
     
  5. red death68

    red death68 Command Sergeant Major

    true but what im figuring is set it to run about once a week and after checking it would ask if i wanted to download the new version which would reduce server load and it wouldnt be running all the time
     
  6. Colemanguy

    Colemanguy MajorGeek

    Just understand that, before running anything not directly human operated its nice to have the owners permission. If i see anything remotely automated running even weekly against my personal site it will trip alarms, and probably get ip banned from access. Just throwing that bit of caution at you. Sounds like your aware tho. Good Luck
     
  7. red death68

    red death68 Command Sergeant Major

  8. Colemanguy

    Colemanguy MajorGeek

    Generaly i try to be helpful in my posts, but i haven't programmed sense vb6 lol. Good luck.
     
  9. GermanOne

    GermanOne Guest

    Haha, OK I see you cannot give up. This works (currently) for Firefox. Not sure whether you already installed it.

    *.vbs
    Code:
    ' local version
    strFileFullName = "C:\Program Files\Mozilla Firefox\Firefox.exe"
    strPropertyName = "ProductVersion"
    
    ' latest version
    strURL = "http://www.mozilla.org/en-US/firefox/fx/"
    strPattern = "http:\/\/download\.mozilla\.org\/\?product=firefox-\d+\.\d+\.\d+&os=win&lang=en-US"
    
    ' find local version
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    strLocal = CreateObject("Shell.Application") _
      .NameSpace(objFSO.GetParentFolderName(strFileFullName)) _
      .ParseName(objFSO.GetFileName(strFileFullName)) _
      .ExtendedProperty(strPropertyName)
    
    ' find latest version in the internet
    On Error Resume Next
    Set objXMLHTTP = CreateObject("Microsoft.XMLHTTP")
    objXMLHTTP.Open "GET", strURL, False
    objXMLHTTP.Send
    If (objXMLHTTP.readyState = 4 And objXMLHTTP.status = 200) Then
      Set objRegEx = New RegExp
      objRegEx.IgnoreCase = True
      objRegEx.Pattern = strPattern
      Set colMatches = objRegEx.Execute(objXMLHTTP.responseText)
      For Each oMatch In colMatches
        strLink = oMatch.Value
      Next
      Set colMatches = Nothing
    Else
      WScript.Echo "Check your internet connection!"
      WScript.Quit
    End If
    Err.Clear
    On Error Goto 0
    Set objXMLHTTP = Nothing
    objRegEx.Pattern = "\d+\.\d+\.\d+"
    Set colMatches = objRegEx.Execute(strLink)
    For Each oMatch In colMatches
      strCurrent = oMatch.Value
    Next
    Set colMatches = Nothing
    Set objRegEx = Nothing
    
    WScript.Echo "Local Firefox version: " & strLocal & _
      vbCrLf & "Latest Firefox version: " & strCurrent
    
    It's simple to find out the local version by reading the extended properties of the exe file.

    More complicated is to select it from the internet. I read the entire source text of the web site (strURL) and match it against a pattern via RegEx to get the download link which contains the version number. Then I extract it out of this string.

    Regards
    GermanOne
     
  10. red death68

    red death68 Command Sergeant Major

    thank you german ill try it soon i gtg get breakfast and get to class im in college now =D
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds