# Write a function that finds all phone numbers from # http://www.virginia.edu/contact # The function then returns a list of all phone numbers # in the area code 434. # If the same phone number appears multiple times, # only one should be reported. # For practice purposes, you should create 2 versions of your solutions. # One version reads a file from the internet; # one version reads a file from your computer (locally). import re import urllib.request def findPhoneNumber(url): phone_list = [] # Define regular expression patter that describes # phone number in area code 434. # Create a regular expression object. regex = re.compile(r'(\(434\) [0-9]{3}-[0-9]{4})') stream = urllib.request.urlopen(url).read().decode('UTF-8') matches = regex.finditer(stream) for match in matches: if match.group() not in phone_list: phone_list.append(match.group()) return phone_list url = "http://www.virginia.edu/contact" print(findPhoneNumber(url))