Python: urllib.request.urlopen() aways returns an error
I am trying to write a Python code like below:
import urllib.request
url = 'http://example.com/'
req = urllib.request.Request(url)
try:
with urllib.request.urlopen(req) as res:
body = res.read()
except urllib.error.HTTPError as e:
print(f"http error: {e.code}")
except urllib.error.URLError as e:
print(f"url error: {e.reason}")
It returns an error which I cannot find a resource on:
url error: [Errno 26] Operation in progress
I've tried this in Safari 17.5 and Chrome 126.0.6478.183.
I'm using an M1 MacBook Air from 2020
Please sign in to leave a comment.