Answer the question
In order to leave comments, you need to log in
How to parse a page when a link is clicked?
Jsoup parses all links and outputs them. By clicking on the link, you need to go to a new Activity to continue parsing. But the shouldOverrideUrlLoading method doesn't work. Here is the code:
protected void onPostExecute(Void result) {
super.onPostExecute(result);
//Тут выводим спарсеное
WebView wv = (WebView) findViewById(R.id.webView);
wv.setWebViewClient(new WebViewClient() {
@SuppressWarnings("deprecation")
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Intent intent = new Intent(MainActivity.this, TrophActivity.class);
startActivity(intent);
return true;}
});
wv.loadData(html,"text/html; charset=utf-8", "UTF-8");
}
Answer the question
In order to leave comments, you need to log in
Solved a problem. It turns out that JSOUP parsed links without a domain, that is, not absolute. Thus shouldOverrideUrlLoading was not called.
Added to parsing:
for( Element urlElement : hrefs ) {
urlElement.attr("href", urlElement.absUrl("href"));
}<spoiler title=""></spoiler>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question