Android Question web scraping

Isac

Active Member
Licensed User
Longtime User
Hello everybody,

does anyone have any ready examples of web scaping?

thank you for your attention
 

walt61

Well-Known Member
Licensed User
Longtime User
Here you go @Isac :

B4X:
Sub Button1_Click

    ' NOTE: if you'd get error "java.security.cert.CertPathValidatorException",
    ' add Conditional Symbol (Ctl-B) 'HU2_ACCEPTALL'
    Wait For (GetWebPageHtml("https://www.b4x.com")) Complete (result As String)
    Log(result)

End Sub

Sub GetWebPageHtml(url As String) As ResumableSub

    ' Dependency: lib OkHttpUtils2

    Dim j As HttpJob
    Dim result As String = ""

    j.Initialize("", Me) 'name is empty as it is no longer needed
    j.Download(url)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        result = j.GetString
    Else
        Log("Error: " & j.ErrorMessage)
    End If
    j.Release
    Return result

End Sub
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
The scraping part can be found in this thread
 
Upvote 1

Isac

Active Member
Licensed User
Longtime User
Here you go @Isac :

B4X:
Sub Button1_Click

    ' NOTE: if you'd get error "java.security.cert.CertPathValidatorException",
    ' add Conditional Symbol (Ctl-B) 'HU2_ACCEPTALL'
    Wait For (GetWebPageHtml("https://www.b4x.com")) Complete (result As String)
    Log(result)

End Sub

Sub GetWebPageHtml(url As String) As ResumableSub

    ' Dependency: lib OkHttpUtils2

    Dim j As HttpJob
    Dim result As String = ""

    j.Initialize("", Me) 'name is empty as it is no longer needed
    j.Download(url)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        result = j.GetString
    Else
        Log("Error: " & j.ErrorMessage)
    End If
    j.Release
    Return result

End Sub

Here you go @Isac :

B4X:
Sub Button1_Click

    ' NOTE: if you'd get error "java.security.cert.CertPathValidatorException",
    ' add Conditional Symbol (Ctl-B) 'HU2_ACCEPTALL'
    Wait For (GetWebPageHtml("https://www.b4x.com")) Complete (result As String)
    Log(result)

End Sub

Sub GetWebPageHtml(url As String) As ResumableSub

    ' Dependency: lib OkHttpUtils2

    Dim j As HttpJob
    Dim result As String = ""

    j.Initialize("", Me) 'name is empty as it is no longer needed
    j.Download(url)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        result = j.GetString
    Else
        Log("Error: " & j.ErrorMessage)
    End If
    j.Release
    Return result

End Sub
Hello
thank you,
but to scrape data from an html page?
do you have any advice?
 
Upvote 0
Top