Skip to content

Commit fbcac79

Browse files
authored
pythongh-141412: Use reliable target URL for urllib example (pythonGH-141428)
The endpoint used for demonstrating reading URLs is no longer stable. This change substitutes a target over which we have more control.
1 parent d162c42 commit fbcac79

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Doc/tutorial/stdlib.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ protocols. Two of the simplest are :mod:`urllib.request` for retrieving data
183183
from URLs and :mod:`smtplib` for sending mail::
184184

185185
>>> from urllib.request import urlopen
186-
>>> with urlopen('http://worldtimeapi.org/api/timezone/etc/UTC.txt') as response:
186+
>>> with urlopen('https://docs.python.org/3/') as response:
187187
... for line in response:
188188
... line = line.decode() # Convert bytes to a str
189-
... if line.startswith('datetime'):
189+
... if 'updated' in line:
190190
... print(line.rstrip()) # Remove trailing newline
191191
...
192-
datetime: 2022-01-01T01:36:47.689215+00:00
192+
Last updated on Nov 11, 2025 (20:11 UTC).
193193

194194
>>> import smtplib
195195
>>> server = smtplib.SMTP('localhost')

0 commit comments

Comments
 (0)