View Raw SPL
/*****************************************************************************
* *
* WEBREADBINARY.SPL Copyright (C) 2021 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Returns the contents of a URL as a series. *
* *
* Revisions: 21 Nov 2021 RRR Creation *
* *
*****************************************************************************/
#if @HELP_WEBREADBINARY
WEBREADBINARY
Purpose: Returns the contents of a URL as a series.
Syntax: WEBREADBINARY("url", "header", bufsize)
(s, retval, errmes) = WEBREADBINARY("url", "header", bufsize)
"url" - A string, the source URL address.
"header " - Optional. A string, the HTML header string. Defaults to empty,
no header.
bufsize - Optional. An integer. The initial size of the HTML
transfer buffer. Defaults to 65536.
Returns: A series, the binary contents of the URL.
(s, retval, errmes) = WEBREADBINARY("url", "header", bufsize)
returns the series result, the result status and an error
message (if any).
Example:
webreadbinary("https://www.dadisp.com")
Returns the HTML text for the DADiSP home page as a binary
series.
Example:
viewtext(strchars(webreadbinary("https://www.dadisp.com")))
Same as above, except the binary data is converted to text
and displayed.
Remarks:
WEBREADBINARY returns the contents of the URL as a series.
See WEBREADSTR to directly return the contents of a URL as
a string.
See WEBREADFILE to save the contents of a URL to a local file.
See Also:
Viewhtml
Webreadfile
Webreadstr
#endif
/* return the contents of URL as a series */
webreadbinary(url = "", header = "", bufsize = 0)
{
local s;
if (strlen(url) == 0)
{
error(sprintf("%s - input URL Required", __FUNC__));
}
if (outargc > 1)
{
(s, retval, errmes) = geturl(url, "", header, "binary", bufsize);
return(s, retval, errmes);
}
else
{
s = geturl(url, "", header, "binary", bufsize);
return(s);
}
}