Platforms to show: All Mac Windows Linux Cross-Platform
/CURL/CURLS text download web 2.0
Required plugins for this example: MBS CURL Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/CURLS text download web 2.0
This example is the version from Wed, 3rd Jan 2023.
Project "CURLS text download web 2.0.xojo_binary_project"
Class App Inherits WebApplication
EventHandler Sub Opening(args() as String)
// add license here
End EventHandler
End Class
Class Session Inherits WebSession
End Class
Class MainPage Inherits WebPage
Control Label1 Inherits WebLabel
ControlInstance Label1 Inherits WebLabel
End Control
Control URLField Inherits WebTextField
ControlInstance URLField Inherits WebTextField
End Control
Control DownloadButton Inherits WebButton
ControlInstance DownloadButton Inherits WebButton
EventHandler Sub Pressed()
DoDownload URLField.Value
End EventHandler
End Control
Control ResultText Inherits WebLabel
ControlInstance ResultText Inherits WebLabel
End Control
Control TextArea1 Inherits WebTextArea
ControlInstance TextArea1 Inherits WebTextArea
End Control
Private Sub DoDownload(URL as string)
dim d as new CURLSMBS
// collect output as we don't have events to handle it right away
d.CollectDebugMessages = true
d.CollectOutputData = true
d.CollectHeaders = true
// write debug log
d.OptionVerbose = true
// download here
d.OptionURL = URL
// if you use SSL, maybe put in a certificate or disable verification?
d.OptionSSLVerifyHost = 0
d.OptionSSLVerifyPeer = 0
// run download
dim e as integer = d.Perform
// check result
dim s as string = d.OutputData
// fix text encoding
if s.Encoding <> nil then
// ok?
elseif encodings.UTF8.IsValidData(s) then
s = DefineEncoding(s, Encodings.UTF8)
else
s = DefineEncoding(s, encodings.ISOLatin1)
End If
// fix line endings
s = ReplaceLineEndings(s, EndOfLine)
TextArea1.Value = s
ResultText.value = "Result: "+Str(e)+" "+d.LasterrorMessage
Dim DebugMessage As String = d.DebugMessages // check in debugger on error
if e <> 0 then
Break
// fix line endings
DebugMessage = ReplaceLineEndings(DebugMessage, EndOfLine)
TextArea1.Value = DebugMessage
End If
End Sub
End Class
Sign
End Sign
End Project
See also:
- /CURL/CURLS get and put/CURLS get and put
- /CURL/CURLS info
- /CURL/CURLS LDAP Query
- /CURL/CURLS Low Level Sockets
- /CURL/CURLS picture download
- /CURL/CURLS post form/CURLS post form
- /CURL/CURLS preemptive threaded upload
- /CURL/CURLS query file size
- /CURL/CURLS simple download compressed
- /CURL/CURLS text download
The items on this page are in the following plugins: MBS CURL Plugin.