Skip to content

Commit

Permalink
fix: requests to unecon website
Browse files Browse the repository at this point in the history
  • Loading branch information
smart7even committed Aug 19, 2023
1 parent 508fca9 commit fb79870
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions parsing/parse_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ def fill_groups(faculty_id: int, course: int):
:param faculty_id: faculty id in the university site
:param course: course number
"""
page = requests.get("https://rasp.unecon.ru/raspisanie.php", params={"fakultet": faculty_id, "kurs": course})
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/39.0.2171.95 Safari/537.36 '
}

page = requests.get("https://rasp.unecon.ru/raspisanie.php", params={"fakultet": faculty_id, "kurs": course}, headers=headers)

if page.status_code == 200:
soup = BeautifulSoup(page.content, features="html.parser")
Expand Down Expand Up @@ -45,7 +50,12 @@ def fill_groups(faculty_id: int, course: int):

def fill_faculties():
"""Fill db with faculties"""
page = requests.get("https://rasp.unecon.ru")
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/39.0.2171.95 Safari/537.36 '
}

page = requests.get("https://rasp.unecon.ru", headers=headers)

if page.status_code == 200:
soup = BeautifulSoup(page.content, features="html.parser")
Expand All @@ -70,7 +80,12 @@ def get_faculty_courses(faculty_id: int):
"""
courses = []

page = requests.get("https://rasp.unecon.ru", {"fakultet": faculty_id})
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/39.0.2171.95 Safari/537.36 '
}

page = requests.get("https://rasp.unecon.ru", {"fakultet": faculty_id}, headers=headers)

if page.status_code == 200:
soup = BeautifulSoup(page.content, features="html.parser")
Expand Down

0 comments on commit fb79870

Please sign in to comment.