GSAK (Geocaching Swiss Army Knife)

Contents - Index

GetUrl (function)

GetUrl(sUrl,[sCaption]) : string

Retrieve the contents of any URL to a variable

sUrl - The Url to get
sCaption -  Oprional, 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. Note: Not all Urls return the size of the contents being downloaded (some web pages for example) so this dialog is mainly only useful when downloading files.

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

$data = GetUrl("")

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

$data = GetUrl("","Getting GSAK patch")
$status = putfile("c:\temp\GSAK721B35.exe",$data)

To download (showing progress) a static image of a Google Map[1] for the current cache (more information on static maps)

# break up the mapurl so it is not just one big long line
$mapurl = ",%lon&zoom=14&size=512x300&maptype=mobile&markers=%lat,%lon,blue"
$mapurl = $mapurl + "&key=ABQIAAAAnfs7bKE82qgb3Zc2YyS-oBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSySz_REpPq-4WZA27OwgbtyR3VcA"

# now fetch the map
$map = GetUrl($mapurl,"... fetching google map")
$status = putfile("c:\temp\map.jpg",$map)

[1] Please read the Google TOU to determine if your intended use of the resulting images from this type of code is acceptable

Related: PostUrl()

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