hello everyone i want to know if there is any way to find url in page loaded in webview for example
webview.loadurl(\"stackoverflow.com\") // this is url
string
Put a first client in your WebView : WebViewClient, in which you'll call the html :
@Override
public void onPageFinished(WebView view, String url) {
webview1.loadUrl("javascript:alert(document.getElementsByTagName('body')[0].innerHTML);");
}
And then, put a second client :
webview1.setWebChromeClient(new MyWebChromeClient());
And in the WebChromeClient, put this, after having declared a boolean navigationTolink to false:
@Override
public boolean onJsAlert(final WebView view, String url, final String transfert, JsResult result) {
if (!navigationtoLink) {
Document html = Jsoup.parse(transfert);
Elements links = html.select("a[href]");
for (Element link : links) {
if (link.attr("href").contains("youtube.com")) {
view.loadUrl(link.attr("href"));
navigationtoLink=true;
}
}
}
This can help for grabbing