def __init__(self, rmpids, interval):
"""
Constructor for RateMyProfessors to set the RMP schools to request and the interval
:param rmpids: **list** List of rmp ids to scrape for
:param interval: **int** Seconds to wait in between scraping
:return:
"""
threading.Thread.__init__(self)
# Pass in a list that contains the the ids to fetch
self.ids = rmpids
# The amount of seconds to wait before scraping RMP again
self.interval = interval
# Establish db connection
self.db = pymongo.MongoClient().ScheduleStorm
log.info("Ensuring MongoDB indexes exist")
self.db.RateMyProfessors.create_index(
[("school", pymongo.ASCENDING)]
)
self.db.RateMyProfessors.create_index(
[("id", pymongo.ASCENDING),
("school", pymongo.ASCENDING)],
unique=True
)
评论列表
文章目录