Learning by doing: Reading books and trying to understand the (code) examples
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

18 lines
431 B

from urllib.request import urlopen
import time
class WebPage:
def __init__(self, url):
self.url = url
self._content = None
@property
def content(self):
now = time.time()
if not self._content:
print("Retrieving new page...")
self._content = urlopen(self.url).read()
print("Got page in {} seconds".format(time.time() - now))
return self._content