''' Purpose: introducing the acquisition of web data -- determine the hidden super power of a CS 1112 person ''' # get access to python web resources import urllib.request # name the location of the people repository BASE_PEOPLE_URL = 'http://www.cs.virginia.edu/~cs1112/people/' # get computing id of interest reply = input( 'Enter computing id: ' ) id = reply.strip() id = id.lower() # specify where in repository we can find the indicated person person_folder = BASE_PEOPLE_URL + id + '/' power_file = person_folder + 'super-power.txt' # get a connection to the web resource of interest stream = urllib.request.urlopen( power_file ) # read stream to get its contents page = stream.read() # decode contents into plain text form text = page.decode( 'UTF-8' ) # text is the superpower of interest print( text )