There is a link to a site with a schedule. On the page there are 3 elements <select>
: Institute (faculty), course, group. How to get the desired table through Requests? I tried Post and Get, unsuccessfully.
JavaScript
x
10
10
1
import requests
2
3
data = {
4
"table11": "597",
5
"crs": "2",
6
"table2": "2973",
7
"name" : "СРВ-21-А"
8
}
9
res = requests.get("http://uiiit.donnuet.ru/raspisanie/index.php", data=data)
10
Maybe Requests will not help here at all, and it is better to try Selenium?
Advertisement
Answer
You can use BeautifulSoup to parse the elements:
JavaScript
1
21
21
1
import requests
2
from bs4 import BeautifulSoup
3
data = {
4
"table11": "597",
5
"crs": "2",
6
"table2": "2973",
7
"name" : "СРВ-21-А"
8
}
9
res = requests.get("http://uiiit.donnuet.ru/raspisanie/index.php", data=data)
10
11
soup = BeautifulSoup(res.text, 'html.parser') # parse the response text
12
table = soup.find('table') # get the table
13
table_body = table.find('tbody') # get the table body
14
rows = table_body.find_all('tr') # get all table rows
15
16
data = []
17
for row in rows: # loop over every row
18
cols = row.find_all('td') # find every column in this row
19
cols = [ele.text.strip() for ele in cols] # get the text in every column
20
data.append([ele for ele in cols if ele]) # append it to the data list
21
Unfortunately I dont speak russian.
To get the table it seems like you have to request
JavaScript
1
2
1
http://uiiit.donnuet.ru/raspisanie/tablemain.php
2
providing data for an field named id
and one named names