After different checks I conclude that the same result is not obtained between WebView and OkHttpUtils2.
The objective is to obtain the data through Service Module, so I must use OkHttpUtils2, but I can not get them from Yahoo or AcuWeather because to the same url's ::
Job.GetString generates a different response ::
from WebView::
Someone can help me with obtaining this data.
Thank you very much in advance.
Attach source proyect!.
Need: Core V8.50, LabelExtras1.12, OkHttpUtils2.70, RuntimePervissions1.10, StringUtils1.12, WebViewExtras1.42
The objective is to obtain the data through Service Module, so I must use OkHttpUtils2, but I can not get them from Yahoo or AcuWeather because to the same url's ::
B4X:
Dim UrlAemet As String = "http://www.aemet.es/es/eltiempo/prediccion/municipios/zaragoza-id50297"
Dim UrlYahoo As String = "https://es.noticias.yahoo.com/tiempo/españa/zaragoza/zaragoza-779063/"
Dim UrlAcuWh As String = "https://www.accuweather.com/es/es/zaragoza/306788/daily-weather-forecast/306788"
Dim UrlcDola As String = "http://cincodias.com/mercados/divisas/eurosxdolares_usa/41/"
Job.GetString generates a different response ::
B4X:
Sub JobDone(Job As HttpJob)
Dim xHtml As String
If Job.Success = True Then
xHtml = Job.GetString
Select Job.JobName
Case "JbAemet"
File.WriteString(DirOut, FileHtml, xHtml)
Case "JbYahoo"
File.WriteString(DirOut, FileHtml, xHtml)
Case "JbAcuWh"
File.WriteString(DirOut, FileHtml, xHtml)
Case "JbDolar"
File.WriteString(DirOut, FileHtml, xHtml)
End Select
ProcessHTML(xHtml)
Else
xHtml = Job.ErrorMessage
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
Job.Release
ProcessHTML(xHtml)
End If
Job.Release
End Sub
from WebView::
B4X:
Sub WebView1_PageFinished (Url As String)
Dim Javascript As String = "B4A.CallSub('ProcessHTML', false, document.documentElement.outerHTML)"
WebViewExtras1.ExecuteJavascript(WebView1, Javascript) ' WebViewExtras 1.42
'WebViewExtras1.ExecuteJavascript(Javascript) ' WebViewExtras2 no fire ProcessHtml
End Sub
B4X:
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
Html = Html.Replace(Chr(34), "'")
Do While Html.IndexOf(CRLF & CRLF) >= 0
Html = Html.Replace(CRLF & CRLF, CRLF)
Loop
If Html.IndexOf("<title>Google</title>") < 0 Then
File.WriteString(DirOut, FileHtml, Html)
GetDataAndPrintResult(Html)
End If
End Sub
Someone can help me with obtaining this data.
Thank you very much in advance.
Attach source proyect!.
Need: Core V8.50, LabelExtras1.12, OkHttpUtils2.70, RuntimePervissions1.10, StringUtils1.12, WebViewExtras1.42
Attachments
Last edited: