emendelson Posted May 16, 2006 Share Posted May 16, 2006 I'm trying to include a routine in a script that can download the current version of the Ghostscript Postscript interpreter, which is always found here:ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/current/and always a filename in this format:gs853w32.exewhere 853 is the current version (8.53).Since the current version changes from time to time, I want to be able to download whatever file is in there named gs???w32.exe.Obviously, this kind of thing won't work, because InetGet requires a filename:InetGet("ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/current/gs???w32.exe", "gsinstall.exe", 1)But I wonder what the alternative might be? Possibly some way of reading this page:http://www.cs.wisc.edu/~ghost/and seeing what numbers are on the end of the line that begins "Obtaining AFPL Ghostscript" or reading the HTML code to test these two lines:<li><b><a href="doc/AFPL/get853.htm">Obtaining AFPL Ghostscript8.53</a></b></li>Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 16, 2006 Moderators Share Posted May 16, 2006 (edited) Well if you are going to download the source to a file you could use this, just uncomment the example $h_FRead and take out the $h_FRead = $s_FilePath$HtmlCode = '<li><b><a href="doc/AFPL/get853.htm">Obtaining AFPL Ghostscript 8.53</a></b></li>' $GetVersion = _StringRegExp_Between($HtmlCode, "Obtaining AFPL Ghostscript", "</a>") If IsArray($GetVersion) Then MsgBox(0, '', StringStripWS($GetVersion[0], 8)) ;InetGet("ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/current/gs" & StringStripWS($GetVersion[0], 8) & "w32.exe", "gsinstall.exe", 1) EndIf Func _StringRegExp_Between($s_FilePath, $s_Start, $s_End) $h_FRead = $s_FilePath; Only using this as an example, since you would be downloading the source anyway uncomment next line and take this one out ;$h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath)) $a_Array = StringRegExp($h_FRead, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3) If Not @error Then Return $a_Array EndFunc Edit: Requires Beta Edited May 16, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
emendelson Posted May 16, 2006 Author Share Posted May 16, 2006 Well if you are going to download the source to a file you could use this, just uncomment the example $h_FRead and take out the $h_FRead = $s_FilePath$HtmlCode = '<li><b><a href="doc/AFPL/get853.htm">Obtaining AFPL Ghostscript 8.53</a></b></li>' $GetVersion = _StringRegExp_Between($HtmlCode, "Obtaining AFPL Ghostscript", "</a>") If IsArray($GetVersion) Then MsgBox(0, '', StringStripWS($GetVersion[0], 8)) ;InetGet("ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/current/gs" & StringStripWS($GetVersion[0], 8) & "w32.exe", "gsinstall.exe", 1) EndIf Func _StringRegExp_Between($s_FilePath, $s_Start, $s_End) $h_FRead = $s_FilePath; Only using this as an example, since you would be downloading the source anyway uncomment next line and take this one out ;$h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath)) $a_Array = StringRegExp($h_FRead, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3) If Not @error Then Return $a_Array EndFunc Edit: Requires Beta I think that's the answer, SmOke_N, thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now