Hello,
I need to do a pretty simple thing, which is exact the source code of a webpage, i.e. google.com or whatever, so that I can parse it later on.
I added a WebView to my app and then using the WebViewExtras lib I tried the following:
Sub WebView1_PageFinished (Url As String)
' Now that the web page has loaded we can get the page content as a String
Dim JS1 As String
JS1 = "B4A.CallSub('ProcessHTML', true ,document.documentElement.outerHTML)"
Log("PageFinished: " & JS1)
MyWebViewExtras.executeJavascript(WebView1, JS1)
End Sub
Sub ProcessHTML(Html As String)
' This is the Sub that we'll get the web page to send it's HTML content to
' Log may truncate a large page so you'll not see all of the HTML in the log but the 'html' String should still contain all of the web page HTML
Log("ProcessHTML: " & Html)
End Sub
So far, the ONLY thing I get in my log is:
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
PageFinished: B4A.CallSub('ProcessHTML',true,document.documentElement.innerHTML)
So... it stops at that, no source code... Do you have any suggestions?
Thank you!
Adrian
I need to do a pretty simple thing, which is exact the source code of a webpage, i.e. google.com or whatever, so that I can parse it later on.
I added a WebView to my app and then using the WebViewExtras lib I tried the following:
Sub WebView1_PageFinished (Url As String)
' Now that the web page has loaded we can get the page content as a String
Dim JS1 As String
JS1 = "B4A.CallSub('ProcessHTML', true ,document.documentElement.outerHTML)"
Log("PageFinished: " & JS1)
MyWebViewExtras.executeJavascript(WebView1, JS1)
End Sub
Sub ProcessHTML(Html As String)
' This is the Sub that we'll get the web page to send it's HTML content to
' Log may truncate a large page so you'll not see all of the HTML in the log but the 'html' String should still contain all of the web page HTML
Log("ProcessHTML: " & Html)
End Sub
So far, the ONLY thing I get in my log is:
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
PageFinished: B4A.CallSub('ProcessHTML',true,document.documentElement.innerHTML)
So... it stops at that, no source code... Do you have any suggestions?
Thank you!
Adrian