from URLs and :mod:`smtplib` for sending mail::
>>> from urllib.request import urlopen
- >>> with urlopen('http://worldtimeapi.org/api/timezone/etc/UTC.txt') as response:
+ >>> with urlopen('https://docs.python.org/3/') as response:
... for line in response:
... line = line.decode() # Convert bytes to a str
- ... if line.startswith('datetime'):
+ ... if 'updated' in line:
... print(line.rstrip()) # Remove trailing newline
...
- datetime: 2022-01-01T01:36:47.689215+00:00
+ Last updated on Nov 11, 2025 (20:11 UTC).
>>> import smtplib
>>> server = smtplib.SMTP('localhost')