August 2018
Intermediate to advanced
366 pages
10h 14m
English
The steps for this recipe are as follows:
def fetch_url(url):
"""Fetch content of a given url from the web"""
import urllib.request
response = urllib.request.urlopen(url)
return response.read()
def wait_until(predicate):
"""Waits until the given predicate returns True"""
import time
seconds = 0
while not predicate():
print('Waiting...')
time.sleep(1.0)
seconds += 1
print('Done!')
return seconds