GSAK (Geocaching Swiss Army Knife)
Contents - Index

GetUrl (function)

GetUrl(sUrl,[sCaption],[nTimeout]) : string

Retrieve the contents of any URL to a variable

sUrl - The Url to get

sCaption -  Optional, default is "". Set to a non empty value to show a dialog with the percentage status of the download, and this caption in the title bar. Useful when downloading large files. Set to "" or leave out this parameter when downloading small files or web pages and you don't need this status.

Note1: Not all Urls return the size of the contents being downloaded so the percentage may not change.

Note2: The special caption "AddHeader:" can be used to add headers to the URL. For more information see this link

Note3: If the Url is a file download (especially a large file) then in the caption use <filename:OutputFileName> where "OutputFileName" is the fully qualified file name where the data will be saved. For more information see this link

nTimeout - Optional, default is 30. The number of seconds to wait before the terminating (because of no response from the server)

For example, to get the raw HTML code for the main page of the GSAK web site:
 

$Data = GetUrl("http://gsak.net")
IF Equal(Left($Data,7),"*error*")
  MsgOk msg=$data
  Cancel
ENDIF


To download (showing progress status) and save a file (the example if one of the GSAK patches):
  

$status = GetUrl("http://gsak.info/GSAK721B35.exe","<filename:c:\temp\GSAK721B35.exe>Getting GSAK patch")

  
Note: If Get URL encounters an error then the return string will begin with "*error*" (without the quotes)

 

Related: PostUrl()


Alpha List         Category List
 
Copyright 2004-2019 CWE Computer Services  
Privacy Policy Contact