Download html

magarcan

Active Member
Licensed User
Longtime User
I want to log into a webservice, and then download a html file that will be parsed.

Now, I can login and download file, but I'm not sure if I'm doing thinks by the right way. Any helps?

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim postData As String
   Dim uri As String

End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("Login.bal")
   uri="https://www.web.com/file.htm"'html file to download

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Continuar_Click
   postData = "user=XXXXX&passwod=XXXX"'User/Password
    PostUrl = "http://www.web.com/check"
    
    HttpUtils.CallbackActivity = "Main"
    HttpUtils.CallbackJobDoneSub = "Job1Done"
    HttpUtils.CallbackUrlDoneSub = "UrlDone"
    Msgbox("Enviar URL","")
    HttpUtils.PostString ("Job1",PostUrl,postData)
   
End Sub

Sub UrlDone(Url As String)
    Log(Url & " done")

End Sub
Sub Job1Done (Job As String)
   Log(Job & " done")
   
   'Successful login must be checked before try to download file
   HttpUtils.CallbackJobDoneSub = "Job2Done"
   HttpUtils.Download("Job2", uri)

End Sub

Sub Job2Done (Job As String)

   Dim s As String
   If HttpUtils.IsSuccess(uri) Then
      s = HttpUtils.GetString(uri)
      Log(s)
   End If

End Sub
Please take a look to my code :eek:

Do you know any easy way to parse the downloaded html file?

Thanks!!
 
Last edited:
Top