ph_geturl PowerHome formula function
Description
Gets the resulting HTML code from a URL.
Syntax
ph_geturl ( url )
Argument Description
url String identifying the URL you wish to retrieve.
Return value
String. The HTML text from the URL. You can include the http:// but it is not necessary. You may also embed any passed parameters to be used in a GET request. This function will use the proxy server defined under Setup / Preferences if you have the appropriate check made in the Setup / Scripts section.
Usage
Use this function to retrieve and save HTML, text, graphic, or binary data from a URL to a file.
Examples
The following examples demonstrate typical syntax/ usage for this function.
• ph_geturl( "mobile.wunderground.com/cgi-bin/findweather/getForecast?brand=mobile&query=48118")
• ph_geturl( "www.adp.com/status&myhomenum=5551212" )

NOTE: This function makes the access call using a Microsoft Internet Explorer activeX control. The user agent that this control and function makes will depend upon your OS and version of IE installed. Depending on your system user agent parameters, the geturl function may not get the source code exactly matching the page, as it is only exposed the interface that passes the URL and can only retrieve what it says is the returned data.

After fetching a web page, if you encounter unexplained issues trying to do string matches, that seem to fail when they shouldn't, consider using the ph_writefile() function to grab the page's HTML code for detailed examination. You may be surprised to find that there can be some significant differences from what you expect, such as capitalization changes or dropped quotation (") marks.

You can capture a web page to a file for more detailed analysis using something like the following example, where "save.txt" is a file to save to, and the getvar function extracts the contents of LOCAL1, which contains the data fetched by the the guturl function.

   ph_writefile("C:\save.txt",1,ph_getvar_s(1,1)) function