loadurl
loadurl
VARIABLE
,
URL

The loadurl statement loads a resource from the internet.

Parameters

This statement has two parameters:

variable – is the name of the field or variable into which you wish to place the downloaded resource (usually text).

url – is the address of the resource to be loaded, for example `"http://www.apple.com"`.

Description

This statement loads a resource from the internet, for example a web page or an image. For example, this procedure will display the home page of the Apple web site.

    local webPage
    loadurl webPage,"http://www.apple.com"
    displaydata webPage

Note that when we say “display”, we actually mean it displays the HTML source of the page, not what you would see in a web browser. (Of course you can use Panorama’s Web Browser object to actually display a web page in a form.

Unlike Panorama 6.0 and earlier, the loadurl statement doesn’t always return text – it can also return binary data. This can be handy if you are downloading a non-text resource, for example an image. However, in some cases loadurl will return binary data when you expect text – it depends on the attributes returned by the web server. For example, loading a page from apple.com or google.com results in text, but loading a page from provue.com or nshipster.com returns binary data (at the time this was written). If you know that the data is text, you can just use it as text and it will be converted automatically, or you can use the binarytotext( function to do so explicitly.

    local webPage
    loadurl webPage,"http://www.apple.com"
    displaydata binarytotext(webPage)

Note: If you need more control over loading the resource, use the url( function instead.

Note: The loadurl statement uses HTTP GET to retrieve the resource. If you want to use HTTP PUT, use the posturl(, url( or urltask( function.

Note: The loadurl statement is synchronous. This means that Panorama stops in its tracks until the communication is complete, so you should avoid this function if possible and use urltask( instead.

See Also

- encodehttppostdata( -- converts a dictionary into HTTP post data.
- info("httpheaders") -- returns a dictionary with information about a just completed HTTP download.
- info("urltaskinfo") -- returns information about a just completed HTTP download.
- ipaddress -- returns the current IP address of the computer, or "" if not connected.
- loadurl( -- loads a resource from the internet.
- posturl -- loads a resource from the internet, with form data.
- posturl( -- loads a resource from the internet, with form data.
- url( -- synchronously loads a resource from the internet.
- urltask( -- asynchronously loads a resource from the internet.
- urltaskcancel -- aborts a download initiated with the urltask( function.
- urltaskstatus -- enables connection error checking in urltask( completion code.
- zipinfo -- queries the web to obtain information about a zip code.
- zipinfoplus -- queries the web to obtain information about a zip code.

History

Version | Status | Notes
10.0 | Updated | Carried over from Panorama 6.0, but now can return binary data as well as text.