pittcsc / PittAPI

An API to easily get data from the University of Pittsburgh
https://pittapi.pittcsc.org
GNU General Public License v2.0
105 stars 30 forks source link

Exception of course caused by the edge case #112

Closed hyprocritor closed 5 years ago

hyprocritor commented 5 years ago

Value Error Exception due to the different date format. Reproduction: Try to get subject of ADMJ for the term 2197. This cased happened on the date part of https://psmobile.pitt.edu/app/catalog/classsection/UPITT/2197/19872

RitwikGupta commented 5 years ago

Could you post the error trace?

hyprocritor commented 5 years ago
C:\Users\chenz\PycharmProjects\untitled\venv2\Scripts\python.exe C:/Users/chenz/PycharmProjects/untitled/entry.py
Processing SUBJECT = ADMJ
Traceback (most recent call last):
  File "C:/Users/chenz/PycharmProjects/untitled/entry.py", line 7, in <module>
    clas[sub] = course.get_term_courses(term='2197', subject=sub)
  File "C:\Users\chenz\PycharmProjects\untitled\venv2\lib\site-packages\PittAPI\course.py", line 381, in get_term_courses
    container.parse_webpage(response)
  File "C:\Users\chenz\PycharmProjects\untitled\venv2\lib\site-packages\PittAPI\course.py", line 86, in parse_webpage
    class_data=child.text.strip().split('\n')
  File "C:\Users\chenz\PycharmProjects\untitled\venv2\lib\site-packages\PittAPI\course.py", line 184, in __init__
    self.__set_properties(class_data)
  File "C:\Users\chenz\PycharmProjects\untitled\venv2\lib\site-packages\PittAPI\course.py", line 208, in __set_properties
    self.end_date = datetime.strptime(date[1], '%m/%d/%Y')
  File "C:\Users\chenz\AppData\Local\Programs\Python\Python37-32\lib\_strptime.py", line 577, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "C:\Users\chenz\AppData\Local\Programs\Python\Python37-32\lib\_strptime.py", line 362, in _strptime
    data_string[found.end():])
ValueError: unconverted data remains: , 06/18/2019

Process finished with exit code 1

There is a few bugs need fix. You can try to run the from PittAPI import course

clas = {}

for sub in course.SUBJECTS:
    print("Processing SUBJECT = " + sub)
    clas[sub] = course.get_term_courses(term='2197', subject=sub)
    for cl in clas[sub].to_dict():
        print(clas[sub][cl].sections)
azharichenko commented 5 years ago

@czk1997 Thanks for the code and output, I'm currently working on it!