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.
import requests data = { "table11": "597", "crs": "2", "table2": "2973", "name" : "СРВ-21-А" } res = requests.get("http://uiiit.donnuet.ru/raspisanie/index.php", data=data)
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:
import requests from bs4 import BeautifulSoup data = { "table11": "597", "crs": "2", "table2": "2973", "name" : "СРВ-21-А" } res = requests.get("http://uiiit.donnuet.ru/raspisanie/index.php", data=data) soup = BeautifulSoup(res.text, 'html.parser') # parse the response text table = soup.find('table') # get the table table_body = table.find('tbody') # get the table body rows = table_body.find_all('tr') # get all table rows data = [] for row in rows: # loop over every row cols = row.find_all('td') # find every column in this row cols = [ele.text.strip() for ele in cols] # get the text in every column data.append([ele for ele in cols if ele]) # append it to the data list
Unfortunately I dont speak russian.
To get the table it seems like you have to request
http://uiiit.donnuet.ru/raspisanie/tablemain.php
providing data for an field named id
and one named names