""" Some basic functionality for reading data from web pages """ from urllib.request import urlopen def print_data(url): """ Prints the data of the webpage found at the provided URL :param url: (str) the URL of the webpage to print its data :return: (None) """ reader = urlopen(url) # print the data a line at a time from the iterable reader for line in reader: print(line) print(type(line)) reader.close() def print_url_data(url): """ Prints the data of the webpage found at the provided URL following the ISO-8859-1 format :param url: (str) the URL of the webpage to print its data :return: (None) """ reader = urlopen(url, timeout=2) for line in reader: print(line.decode('ISO-8859-1').strip()) reader.close()