From Liberty BASIC Family
Jump to navigation Jump to search
Not supported in Just BASIC Not supported in Liberty BASIC Not supported in Liberty BASIC 5 Supported in Run BASIC


The httpget$() function uses the HTTP protocol to get the contents of a web document using a URL. The document is returned as a string.


  1. HTTPGET$(urlExpr$) - Perform an HTTP GET and return the result


Place useful hints about this keyword here


'httpget$() function used to obtain your current external IP address. 
'No parsing is required, the page returns nothing but the IP. 

url$ = ""

r$ = httpget$(url$)
print r$
This demo retrieves the index page at and prints the result.
'Retrieve the webpage at 
'and print it.
print httpget$("")
The next demo assigns the contents of the "What's New" Liberty BASIC page to a string variable, then prints that variable.
'The function can also be used this way.
'The web page news.html is assigned to the
'string variable stuff$, then printed
stuff$ = httpget$("")
print stuff$
Other kinds of files can be retrieved with this function. The following demo, modified from one that was shared by Carl, retrieves an image file with HTTPGET$(). It then creates a binary file on disk and writes the results of HTTPGET$() to disk. The disk file image is then loaded with LOADIMAGE and displayed in a graphic object.
'To retrieve an image file, assign it to
'a string variable:
pic$ = httpget$("")

'Create a disk file, then write the 
'image information to disk.
open "lb3banner.jpg" for binary as #1
print #1, pic$
close #1

'Load the image and display it in a graphic object.
loadimage "banner", "lb3banner.jpg"
graphic #g, 500, 100
#g drawimage("banner",0,0)
render #g

Useful Procedures

' Place a useful function or sub using this keyword here