2

Здравствуйте. Пишу приложение для андроид, которое парсит с копроративной странички график работы. На исходной странице имеется одна таблица, в которой содержатся графики на все 12 месяцев для каждого сотрудника отдела. Всего в таблице около 600-650 строк. При выполнении этого кода:

Document doc = Jsoup.connect("http://url.htm").get();

в doc, как и положено, сохраняется документ. Однако следующее выражение:

doc.select("tr").size();

возвращает число 451. Первые 451 строк парсятся без проблем (почти), а где остальные?

Вот кусок когда исходной страницы:

<tr height=17 style='height:12.75pt'>
  <td height=17 class=xl9817500 style='height:12.75pt;border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6817500 style='border-top:none'>&nbsp;</td>
  <td class=xl12217500 style='border-top:none'>0</td>
  <td class=xl12217500 style='border-top:none'>0</td>
  <td class=xl13817500 style='border-top:none'>0</td>
  <td class=xl13117500 style='border-top:none'>0</td>
  <td class=xl13117500 style='border-top:none'>0</td>
  <td class=xl10517500 style='border-top:none'>0</td>
  <td class=xl6553517500></td>
  <td class=xl6553517500></td>
  <td class=xl6553517500></td>
 </tr>
 <tr height=17 style='height:12.75pt'>
  <td height=17 class=xl9817500 style='height:12.75pt;border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6717500 style='border-top:none'>&nbsp;</td>
  <td class=xl6917500 style='border-top:none'>&nbsp;</td>
  <td class=xl6817500 style='border-top:none'>&nbsp;</td>
  <td class=xl12217500 style='border-top:none'>0</td>
  <td class=xl12217500 style='border-top:none'>0</td>
  <td class=xl13817500 style='border-top:none'>0</td>
  <td class=xl13117500 style='border-top:none'>0</td>
  <td class=xl13117500 style='border-top:none'>0</td>
  <td class=xl10517500 style='border-top:none'>0</td>
  <td class=xl6553517500></td>
  <td class=xl6553517500></td>
  <td class=xl6553517500></td>
 </tr>

Из таких tr и td состоит вся страница. Я привел кусок, на котором и обрывается документ. Скачаный jsoup'ом документ doc заканчивается на второй (в приведенном коде) tr, на 23-й по счету td. Насколько я понимаю, таблица сформирована автоматически:

<!--[if !excel]>&nbsp;&nbsp;<![endif]-->
<!--Следующие сведения были подготовлены мастером публикации веб-страниц
Microsoft Excel.-->
<!--При повторной публикации этого документа из Excel все сведения между тегами
DIV будут заменены.-->
<!----------------------------->
<!--НАЧАЛО ФРАГМЕНТА ПУБЛИКАЦИИ МАСТЕРА ВЕБ-СТРАНИЦ EXCEL -->
<!----------------------------->

Подскажите пожалуйста, в чем может быть проблема?

1
  • Попробуйте посмотреть содержимое doc.
    – post_zeew
    2 окт 2016 в 10:14

1 ответ 1

2

Спасибо, нашел ответ на свой вопрос тут

в моем случай проблема решилась методом .maxBodySize(0).

Document doc = Jsoup.connect("http://url.htm").maxBodySize(0).get();

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.