Fastest way to obtain web source with javascript in android

Viewed 155

I'm currently trying to get the source of some page from android.

From pre-checking the source, it contains javascript in it.

In order to be able to parse it correctly by using jsoup, I had to do the following steps:

  1. Load the url into a webView.

  2. use jsoup.parse() on the webView to get the source with the javascript in it.

     wb_result.setVisibility( View.GONE );
     wb_result.getSettings().setSaveFormData( false );
     wb_result.getSettings().setBlockNetworkLoads( true );
     wb_result.addJavascriptInterface( new MyJavaScriptInterface( this ), "HtmlViewer" );
     wb_result.setWebViewClient( new WebViewClient() {
    
         @Override
         public void onPageFinished(WebView view, String url) {
    
                wb_result.loadUrl( "javascript:window.HtmlViewer.showHTML" +
                             "('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>');" );
    
         }
    
     } );
    

In my opinion, it is a little weird to have a webView in my activity and keep its visibility GONE and only to use it as a middle step in order to get to the source I need + it is slow.

I was wondering what is the fastest solution to obtain a source that contains javascript.

I read about Chrome Custom Tabs and that it should be faster but then I can't hide the opened tab from what I saw and it will disturb the flow of the app.

Specifically, the url im trying to get its source is - link.

Any modern ideas? all the solutions I saw are from 2016.

Thank you

0 Answers
Related