I am using urllib.request to open a page source with Python 3.2.1, but I am getting an error saying urllib.error.HTTPError: HTTP Error 503: Service Unavailable
. Please find the code and error below.
import re
import urllib.request
html = urllib.request.urlopen("http://www.pythonchallenge.com/pc/def/ocr.html").read().decode()
print (html)
Traceback (most recent call last):
File "I:/Private/nabm/python/python_challenge/python_challenge_2.py", line 4, in <module>
html = urllib.request.urlopen("http://www.pythonchallenge.com/pc/def/ocr.html").read().decode()
File "C:\appl\Python\3.2.1\lib\urllib\request.py", line 138, in urlopen
return opener.open(url, data, timeout)
File "C:\appl\Python\3.2.1\lib\urllib\request.py", line 375, in open
response = meth(req, response)
File "C:\appl\Python\3.2.1\lib\urllib\request.py", line 487, in http_response
'http', request, response, code, msg, hdrs)
File "C:\appl\Python\3.2.1\lib\urllib\request.py", line 413, in error
return self._call_chain(*args)
File "C:\appl\Python\3.2.1\lib\urllib\request.py", line 347, in _call_chain
result = func(*args)
File "C:\appl\Python\3.2.1\lib\urllib\request.py", line 495, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Unavailable
Process finished with exit code 1
Could anyone see what could be causing this error?
HTTP error 503 means that the server wasn't able to respond at that moment, either due to overload or because it refused your connection. In other words, there is nothing you can change in your code to fix it.