""" Purpose: introduce CS 1112 module url there is a module called url.py. we have a function in that module called get_contents() that does a lot of yucky processing for us to hand back a string of whatever is on a website url that you provide we'll learn how to write cool functions too :) **this module is fair game for test 1 on Monday 9/27** do not make a new folder for the exam. move past code that is no longer relevant to a subfolder if you need more organization, but don't start a new folder or project because it can mess up the interpreter and we like to avoid stress """ # get access to web-based data support import url # import is a new keyword for us. it tells python we want to access code from a different .py file # ** URL.PY MUST BE IN YOUR CS 1112 PROJECT FOLDER ** # set data web folder location WORDS_WEB_FOLDER = "http://www.cs.virginia.edu/~cs1112/datasets/words/" # this will be provided # this is the base location that we are interested in, will always end in a / (not part of folder name) # set file name file_name = "word-of-the-day" # this is a special file in the words folder # specify link link = WORDS_WEB_FOLDER + file_name print( "link:", link ) # never hurts to check that your link is working! # link anatomy is going to be the base location + the specific file name, use + not a , # read web page contents = url.get_contents( link ) # Professor Cohoon wrote a function called get_contents() that will hand back whatever is at that link # this information is handed back as a string! # clean up word = contents.strip() # cleaning up a string could mean many things, but strip() rarely hurts # reveal word print( word )