Beispiel #1
0
def saveCourseDict():
	startTime = time.clock()
	cfg = loadConfig()
	season = cfg['oneStop']['season']
	year = cfg['oneStop']['year']
	courseDataDir = cfg['dataLoc']['courseDataDir']
	dataExt = cfg['dataLoc']['courseDataExt']

	# **** is the abbreviation for 'all subjects'
	oneStopLookupUrl = oneStopUtils.getOneStopSearchUrl(season, year, '****')

	timeScraped = unixTime()

	# retrieve html from OneStop
	htmlObj = urllib2.urlopen(oneStopLookupUrl)
	rawHtml = htmlObj.read()

	courseDict = bsParseHtml(rawHtml)

	with open(courseDataDir + '/' + str(timeScraped) + '.' + dataExt, 'w') as dataOut:
		cPickle.dump(courseDict, dataOut)

	totalTime = time.clock() - startTime
	return totalTime