Script BASIC

Script BASIC => Tutorials => Topic started by: support on July 10, 2010, 10:41:36 PM

Title: cURL Example
Post by: support on July 10, 2010, 10:41:36 PM
The following cURL extension module example retrieves a web page HTML and saves it to your PC. (webget)

Code: [Select]
' cURL webget

INCLUDE curl.bas

ch = curl::init()
curl::option(ch,"URL","http://scriptbasic.com/html/general.html")
curl::option(ch,"FILE","general.html")
curl::perform(ch)
curl::finish(ch)

cURL extension module documentation (http://www.scriptbasic.org/docs/curl/mod_curl_toc.html)


Here is a webget by opening a TCP socket using ScriptBasic.

Code: [Select]
OPEN "scriptbasic.com/html/general.html:80" for SOCKET AS #1
PRINT #1,"GET http://localhost/ HTTP/1.0\n\n"
WHILE NOT EOF(1)
  LINE INPUT #1, content
  PRINT content
WEND
CLOSE(1)