A
A
Aleviy2021-03-12 14:48:56
Python
Aleviy, 2021-03-12 14:48:56

How to correctly display a table in Python bs4?

I want to parse information from the university website (schedule). Here is the HTML code that I get after submitting a POST request to the site and searching

<tr><th width="96px">Время</th>
<th colspan="2">Дисциплина, преподаватель</th>
<th width="40px">к./ауд.</th></tr>
<tr><td class="wday" colspan="5">пятница (12.3.2021)</td></tr>
<tr><td rowspan="8">8:15-9:35</td>
<td colspan="3">Иностранный язык <span class="distype">(Занятия в составе подгруппы)</span></td></tr>
<tr><td class="sg" rowspan="1">подгр.а1</td>
<td><span class="teacher">Казючиц Галина Евгеньевна</span></td>
<td rowspan="1">2/320<!--0, igrp 0, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="sg" rowspan="1">подгр.а2</td>
<td><span class="teacher">Мех Татьяна Ивановна</span></td>
<td rowspan="1">2/422<!--1, igrp 0, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="sg" rowspan="1">подгр.а3</td>
<td><span class="teacher">Ушакова Лариса Михайловна</span></td>
<td rowspan="1">2/424<!--2, igrp 0, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="sg" rowspan="1">подгр.а4</td>
<td><span class="teacher">Круталевич Алла Федоровна</span></td>
<td rowspan="1">2/425<!--3, igrp 0, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="sg" rowspan="1">подгр.а5</td>
<td><span class="teacher">Савчук Юлия Михайловна</span></td>
<td rowspan="1">2/426<!--4, igrp 0, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="sg" rowspan="1">подгр.а6</td>
<td><span class="teacher">Березовская Светлана Николаевна</span></td>
<td rowspan="1">2/428<!--5, igrp 0, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="sg" rowspan="1">подгр.нем</td>
<td><span class="teacher">Бартош Виктор Степанович</span></td>
<td rowspan="1">2/420<!--6, igrp 0, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td rowspan="2">9:45-11:05</td>
<td colspan="3">Культура страны изучаемого языка <span class="distype">(Лекции)</span></td></tr>
<tr><td class="sg" rowspan="1">подгр.англ</td>
<td><span class="teacher">Белова Ксения Александровна</span></td>
<td rowspan="1">1/706<!--7, igrp 7, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td rowspan="2">11:15-12:35</td>
<td colspan="3">Культура страны изучаемого языка <span class="distype">(Семинары)</span></td></tr>
<tr><td class="sg" rowspan="1">подгр.нем</td>
<td><span class="teacher">Босак Алёна Анатольевна</span></td>
<td rowspan="1">2/420<!--8, igrp 8, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="right">14:35-15:55</td>
<td colspan="2">Физическая культура <span class="distype">(Практические занятия)</span> ,  <span class="teacher">Шмаргунов Дмитрий Александрович</span></td>
<td class="right"> </td></tr>
<tr><td class="wday" colspan="5">суббота (13.3.2021)</td></tr>
<tr><td rowspan="8">8:15-9:35</td>
<td colspan="3">Иностранный язык <span class="distype">(Занятия в составе подгруппы)</span></td></tr>
<tr><td class="sg" rowspan="1">подгр.а1</td>
<td><span class="teacher">Казючиц Галина Евгеньевна</span></td>
<td rowspan="1">3/429<!--10, igrp 10, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="sg" rowspan="1">подгр.а2</td>
<td><span class="teacher">Мех Татьяна Ивановна</span></td>
<td rowspan="1">2/422<!--11, igrp 10, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="sg" rowspan="1">подгр.а3</td>
<td><span class="teacher">Ушакова Лариса Михайловна</span></td>
<td rowspan="1">2/424<!--12, igrp 10, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="sg" rowspan="1">подгр.а4</td>
<td><span class="teacher">Круталевич Алла Федоровна</span></td>
<td rowspan="1">2/425<!--13, igrp 10, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="sg" rowspan="1">подгр.а5</td>
<td><span class="teacher">Савчук Юлия Михайловна</span></td>
<td rowspan="1">2/426<!--14, igrp 10, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="sg" rowspan="1">подгр.а6</td>
<td><span class="teacher">Березовская Светлана Николаевна</span></td>
<td rowspan="1">2/428<!--15, igrp 10, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="sg" rowspan="1">подгр.нем</td>
<td><span class="teacher">Бартош Виктор Степанович</span></td>
<td rowspan="1">3/440<!--16, igrp 10, week[i]: 5, week[igrp] 5--></td></tr>
<tr><td class="right">9:45-11:05</td>
<td colspan="2">Обязательный модуль "Философия" (Философия) <span class="distype">(Лекции)</span> ,  <span class="teacher">Зубко Мария Васильевна</span></td>
<td class="right">1/706</td></tr>
<tr><td class="right">11:15-12:35</td>
<td colspan="2">Спецмодуль № 1 Экономическая история <span class="distype">(Лекции)</span> ,  <span class="teacher">Сасим Александр Михайлович</span></td>
<td class="right">1/706</td></tr>
<tr><td class="wday" colspan="5">понедельник (15.3.2021)</td></tr>
<tr><td class="right">8:15-9:35</td>
<td colspan="2">Компьютерные информационные технологии <span class="distype">(Лекции)</span> ,  <span class="teacher">Токаревская Наталья Гарьевна</span></td>
<td class="right">3/450</td></tr>
<tr><td class="right">9:45-11:05</td>
<td colspan="2">Спецмодуль № 2  Геополитика <span class="distype">(Семинары)</span> ,  <span class="teacher">Невар В.Н.</span></td>
<td class="right">1/805</td></tr>
<tr><td rowspan="3">11:15-12:35</td>
<td colspan="3">Культура страны изучаемого языка <span class="distype">(Семинары)</span></td></tr>
<tr><td class="sg" rowspan="1">подгр.а1</td>
<td><span class="teacher">Казючиц Галина Евгеньевна</span></td>
<td rowspan="1">2/320<!--21, igrp 21, week[i]: 6, week[igrp] 6--></td></tr>
<tr><td class="sg" rowspan="1">подгр.а2</td>
<td><span class="teacher">Белова Ксения Александровна</span></td>
<td rowspan="1">2/422<!--22, igrp 21, week[i]: 6, week[igrp] 6--></td></tr>
<tr><td rowspan="2">14:35-15:55</td>
<td colspan="3">Русский язык как средство коммуникации <span class="distype">(Практические занятия)</span></td></tr>
<tr><td class="sg" rowspan="1">подгр.русск.яз.</td>
<td><span class="teacher">Кухта Светлана Владимировна</span></td>
<td rowspan="1">2/201<!--23, igrp 23, week[i]: 6, week[igrp] 6--></td></tr>
<tr><td rowspan="2">14:35-15:55</td>
<td colspan="3">Иностранный язык <span class="distype">(Занятия в составе подгруппы)</span></td></tr>
<tr><td class="sg" rowspan="1">подгр.фран.яз.ДФЗ,ДФР,ДФК,ДФФ</td>
<td><span class="teacher">Пантелеева Ирина Викторовна</span></td>
<td rowspan="1">3/228а<!--24, igrp 24, week[i]: 6, week[igrp] 6--></td></tr>
<tr><td rowspan="2">16:05-17:25</td>
<td colspan="3">Русский язык как средство коммуникации <span class="distype">(Практические занятия)</span></td></tr>
<tr><td class="sg" rowspan="1">подгр.русск.яз.</td>
<td><span class="teacher">Кухта Светлана Владимировна</span></td>
<td rowspan="1">3/228а<!--25, igrp 25, week[i]: 6, week[igrp] 6--></td></tr>
<tr><td class="wday" colspan="5">вторник (16.3.2021)</td></tr>
<tr><td class="right">8:15-9:35</td>
<td colspan="2">Микроэкономика <span class="distype">(Лекции)</span> ,  <span class="teacher">Рощенко Анна Викторовна</span></td>
<td class="right">3/441</td></tr>
<tr><td class="right">9:45-11:05</td>
<td colspan="2">Физическая культура <span class="distype">(Практические занятия)</span> ,  <span class="teacher">Шмаргунов Дмитрий Александрович</span></td>
<td class="right"> </td></tr>
<tr><td rowspan="3">11:15-12:35</td>
<td colspan="3">Компьютерные информационные технологии <span class="distype">(Лабораторные занятия)</span></td></tr>
<tr><td class="sg" rowspan="1">подгр.А</td>
<td><span class="teacher">Мартысевич Ольга Васильевна</span></td>
<td rowspan="1">2/402<!--28, igrp 28, week[i]: 6, week[igrp] 6--></td></tr>
<tr><td class="sg" rowspan="1">подгр.Б</td>
<td><span class="teacher">Соколова Наталья Александровна</span></td>
<td rowspan="1">2/301<!--29, igrp 28, week[i]: 6, week[igrp] 6--></td></tr>
<tr><td class="right">13:05-14:25</td>
<td colspan="2">Микроэкономика <span class="distype">(Семинары)</span> ,  <span class="teacher">Рощенко Анна Викторовна</span></td>
<td class="right">1/606</td></tr>

As you can see, the schedule is displayed for a week. I want to display by day (there is no possibility to get information by day from the site initially). Days are separated by
<tr><td class="wday" colspan="5">суббота (13.3.2021)</td></tr>
. Is it possible to set span for bs4? For example, parse everything from
<tr><td class="wday" colspan="5">понедельник (15.3.2021)</td></tr>
before
<tr><td class="wday" colspan="5">вторник (16.3.2021)</td></tr>
and not touch the rest?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question