[英]Jsoup is not working with a webpage
我正在嘗試從網頁獲取某些圖像的URL,但是出現問題。 我正在使用try.jsoup.org通過CSS Query img
解析HTML並獲得結果:
<img src="https://d5nxst8fruw4z.cloudfront.net/atrk.gif?account=JwbPi1a4ZP00iy" style="display:none" height="1" width="1" alt="" />
<img src="http://ads.tamtay.vn/www/delivery/avw.php?zoneid=226&cb=INSET_RANDOM_NUMBER_HERE&n=aa2b62d0" border="0" alt="" />
<img src="http://a0.ttimg.vn/866392.ava" style="width: 100%;" />
我知道通過attr("abs:src")
獲得這些URL非常容易,但是在這種情況下,它不起作用,並返回null
。
我嘗試通過其他網頁更改當前網頁。 它正常工作。 我認為問題來自網頁。 不是代碼。 有人可以幫忙嗎?
為什么只用“ src”嘗試“ abs”
這是代碼:
private class Title extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... params) {
try {
// Connect to the web site
Document document = Jsoup.connect("http://photo.tamtay.vn").get();
Element image = document.select("img").first();
Log.d("Image", image.attr("abs:src"));
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
}
}
image.attr(“ abs:src”)返回null
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.