I am using Jsoup library to extract data from this site: Tom's hardware benchmarks
I use this code for connect to the site and extract data:
protected Void doInBackground(Object[] params) {
doc = Jsoup.connect(url).maxBodySize(Integer.MAX_VALUE).header("Accept-Encoding", "gzip").userAgent("Dalvik").method(Connection.Method.GET).timeout(Integer.MAX_VALUE).get();
try {
if (doc != null) {
css_text = doc.select("div[class=clLeft] label[for]");
for (int i = 0; i < css_text.size(); i++)
elem1[i] = css_text.eq(i).text();
css_text = doc.select("ul[style=margin-left:0px;] span");
css_score = doc.select("div[class=clRight clearfix]");
for (int j = 0; j < css_text.size(); j++) {
elem2[j] = css_text.eq(j).text();
score[j] = css_score.eq(j).text();
processori_score_arraylist.add(elem1[j] + "\n" + elem2[j] + " " + score[j]);
}
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
processori_score_listview.setAdapter(adapter);
}
}
}
I read that there is a default limitation of 1MB, and that can truncate the webpage. This webpage instead don't appear to 1MB so I use first a value by me but don't work always. For a problem that I don't understand, when i am in debug mode and see the variable doc as Document, the webpage is download all sometime and other sometimes not. I don't understand why. Then I try to change the value of maxBodySize to 0 and then to Integer.MAX_VALUE and also timeout value reading other post and search of Internet but it doesn't resolve the problem. Anybody can suggest me cause or solution of the problem? I hope that is clear what the problem is, if not I am available for doubts.
Other post of this problem that I found:
Here the HTML page how is truncated:
<!doctype html>
<html>
<head>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<meta http-equiv="cache-control" content="max-age=0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="refresh" content="10; url=/distil_r_captcha.html?Ref=/charts/cpu-charts-2015/-01-CinebenchR15,Marque_fbrandx14,3693.html&distil_RID=1CB642F0-76B5-11E5-9B22-93799C16BE3F&distil_TID=20151019225954">
<script type="text/javascript">
(function(window){
try {
if (typeof sessionStorage !== 'undefined'){
sessionStorage.setItem('distil_referrer', document.referrer);
}
} catch (e){}
})(window);
</script>
<script type="text/javascript" src="/destilar-fbxcdbtcwcebrsxtw.js" defer></script>
<style type="text/css">#d__fFH{position:absolute;top:-5000px;left:-5000px}#d__fF{font-family:serif;font-size:200px;visibility:hidden}#ssxfwzexyqctzdfy{display:none!important}</style>
</head>
<body>
<div id="distil_ident_block">
</div>
</body>
</html>