Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add 3rd example to chapter1
  • Loading branch information
will-i-amv authored Jun 30, 2021
commit 4121156431580747ece389dcd979657a1e93a9fe
13 changes: 13 additions & 0 deletions v2/chapter1/3-exceptionHandling_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from urllib.request import urlopen
from urllib.error import HTTPError
from urllib.error import URLError


try:
html = urlopen("https://pythonscrapingthisurldoesnotexist.com")
except HTTPError as e:
print("The server returned an HTTP error")
except URLError as e:
print("The server could not be found!")
else:
print(html.read())