MainActivity:
private void getWebsite() {
new Thread(new Runnable() {
@Override
public void run() {
final StringBuilder builder = new StringBuilder();
try {
Document doc = Jsoup.connect(domain + "account").get();
String title = doc.title();
Elements elements = doc.getElementsByClass("gravatar avatar avatar-120");
builder.append(title).append("\n");
for (Element e : elements ) {
builder.append("\n").append("Link : ").append(e.attr("src")) ;
}
} catch (IOException e) {
builder.append("Error : ").append(e.getMessage()).append("\n");
}
Log.d("HTML", builder.toString());
runOnUiThread(new Runnable() {
@Override
public void run() {
//ProfileImgUrl = builder.toString();
result.setText(builder.toString());
}
});
}
}).start();
}
HTML:
other <img> tag
<a href="website link">
<img src="image link" class="gravatar avatar avatar-120" etc...>
</a>
other <img> tag
我希望获得图像链接,但结果是一些其他文本。