So I'm loading a webpage in my app's webview and there's an HTML i class="img profimage"
and it has a background-image url and that's my target...
I want to get that target either with JavaScript or using Jsoup...
What I tried so far with Jsoup is this:
public class GetImage extends AsyncTask<String, String, String> {
protected String doInBackground(String... strings) {
Document document = null;
try {
document = Jsoup.connect(url).get();
} catch (IOException e) {
e.printStackTrace();
}
String temp = document.select("i.img.profpic").first().getElementsByAttribute("style").toString();
return temp.substring(temp.indexOf("(") + 1, temp.indexOf(")"));
}
protected void onPostExecute(String result) {
Log.d("ChatScreen", result);
Toast.makeText(ChatScreen.this, result, LENGTH_SHORT).show();
}
}
But I'm getting NPE...
I don't know how to get background-image url of an i class using JavaScript... I can find plenty of examples on web for how to get it for div
using ids
HTML structure of page is similar to this:
<div ....>
<div ....>
<i class="img profimage" style="background-image: url("url here");"/>
</div>
</div>