XML : Python 3 Read data from URL

I have a problem with python 3 versions when I want to read from URL

  URL="http://"+USER+":"+PASSWORD+"@127.0.0.1:"+PORT+"/manager/status?XML=true"  RURL=urllib.request.urlopen(URL)  XML=RURL.read()  RURL.close()    

In Older Python version is work correctly the following:

  URL="http://"+USER+":"+PASSWORD+"@127.0.0.1:"+PORT+"/manager/status?XML=true"  RURL=urllib.urlopen(URL)  XML=RURL.read()  RURL.close()    

Now when I run the script I get the follow :

Traceback (most recent call last): File "/opt/rh/python33/root/usr/lib64/python3.3/urllib/request.py", line 1248, in do_open h.request(req.get_method(), req.selector, req.data, headers) File "/opt/rh/python33/root/usr/lib64/python3.3/http/client.py", line 1061, in request self._send_request(method, url, body, headers) File "/opt/rh/python33/root/usr/lib64/python3.3/http/client.py", line 1099, in _send_request self.endheaders(body) File "/opt/rh/python33/root/usr/lib64/python3.3/http/client.py", line 1057, in endheaders self._send_output(message_body) File "/opt/rh/python33/root/usr/lib64/python3.3/http/client.py", line 902, in _send_output self.send(msg) File "/opt/rh/python33/root/usr/lib64/python3.3/http/client.py", line 840, in send self.connect() File "/opt/rh/python33/root/usr/lib64/python3.3/http/client.py", line 818, in connect self.timeout, self.source_address) File "/opt/rh/python33/root/usr/lib64/python3.3/socket.py", line 417, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./Tomcatxml.py", line 15, in RURL=urllib.request.urlopen(URL) File "/opt/rh/python33/root/usr/lib64/python3.3/urllib/request.py", line 156, in urlopen return opener.open(url, data, timeout) File "/opt/rh/python33/root/usr/lib64/python3.3/urllib/request.py", line 469, in open response = self._open(req, data) File "/opt/rh/python33/root/usr/lib64/python3.3/urllib/request.py", line 487, in _open '_open', req) File "/opt/rh/python33/root/usr/lib64/python3.3/urllib/request.py", line 447, in _call_chain result = func(*args) File "/opt/rh/python33/root/usr/lib64/python3.3/urllib/request.py", line 1268, in http_open return self.do_open(http.client.HTTPConnection, req) File "/opt/rh/python33/root/usr/lib64/python3.3/urllib/request.py", line 1251, in do_open raise URLError(err) urllib.error.URLError:

No comments:

Post a Comment