Nobelz / RateMyProfessorAPI

Python web scraper to get professor ratings from ratemyprofessor.com website.
Apache License 2.0
39 stars 11 forks source link

Add "get_first_professor_by_school_and_name" #17

Open RyanCheddar opened 1 year ago

RyanCheddar commented 1 year ago

get_first_professor_by_school_and_name functions like get_professor_by_school_and_name, except it does not check the professors' number of ratings. Instead, it returns the first professor in its search results that a Professor object can be created for.

As it doesn't require rating data, it doesn't need to create a Professor object for every single professor in its search results, therefore increasing performance by making less requests to RMP :DDD

Also, it is useful for when the developer wants to trust RMP's search algorithm, and may not strictly only want the professor with the most ratings.

It duplicates a lot of get_professors_by_school_and_name's code, which slightly sucks, but I also am not sure how else to do things without also sacrificing code readability or losing the performance benefits.