【发布时间】:2016-04-18 21:01:33
【问题描述】:
我的错是什么?
安卓代码:
ArrayList<String> plan_table = new ArrayList<>();
Element table = doc.select("table").get(1); //First Table: Untis Banner and School Data (Adress, etc.); Second Table: Plan -> So load second plan (index 1)
Elements rows = table.select("tr");
Log.i("SchollgymPlanThread","This are the rows: "+rows.toString());
for (int i = 1; i < rows.size(); i++) { //first row is the col names so skip it
Element row = rows.get(i);
Elements cols = row.select("td");
//Log.i("SchollgymPlanThread", cols.get(0).text());
plan_table.add(cols.get(0).text());
if (Pattern.matches("^Klasse .*",cols.get(0).text())) {PlanParsed.put(cols.get(0).text(), new LinkedHashMap<String,List>()); current_class=cols.get(0).text();continue;}
if (current_class != null) {
List<String> tmpList = new ArrayList<String>();
for (int i2 = 1; i2 < cols.size(); i2++) {
if (i2 == 2) {continue;} //If Lessons Hour , continue -> Lesson our will be put as key and not in the list
tmpList.add(cols.get(i2).text());
}
Log.i("SchollgymPlanThread", tmpList.toString());
if (cols.size() < 2) {continue;}
PlanParsed.get(current_class).put(cols.get(2).text(), tmpList); //ParsedPlan[current_class] = {lesson_hour:lesson_attributes}
}
//if ( row.className() == "list odd" ) {Log.i("SchollgymPlanThread","This is a class: "+cols.get(0).text());}
//if (cols.get(7).text().equals("down")) {
// plan_table.add(cols.get(5).text());
//}
我没有插入整个 java 代码,但这就是我遇到问题的地方... 在第 4 行,它打印出带有 td 和 tr 的 html 代码,但它突然停止了。输出的最后一行是:
<td cla
有什么问题吗?我已经检查了源网站...
【问题讨论】:
-
logcat 使用了一个缓冲区,可能你把它填满了。尝试打印到文件,看看输出是否仍然在中间被剪切。
-
我会试试的。感谢优势
-
您的问题解决了吗?如果是这样,请考虑接受答案。如果没有,请重新表述您的问题,以便我们更好地了解如何提供帮助。
-
我无法尝试您的解决方案,因为我的计算机目前无法工作。我正在用我的手机写这个;)当然,如果它有效,我会接受答案;)
标签: java android html networking jsoup