urllib.request.urlopen: ValueError: invalid literal for int() with base 10: '[email protected]'

41 Views Asked by At

When I use urlopen on

https://78d32f2c60e08a06ef4438996e77f198:[email protected]/admin/api/2023-10/orders.json' 

I get this error

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 894, in _get_hostport
    port = int(host[i+1:])
ValueError: invalid literal for int() with base 10: '[email protected]'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/davidhu/PycharmProjects/Code Tester/main.py", line 12, in <module>
    print(main(1))
  File "/Users/davidhu/PycharmProjects/Code Tester/main.py", line 6, in main
    with urlopen(url) as response:
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 517, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 534, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1389, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1315, in do_open
    h = http_class(host, timeout=req.timeout, **http_conn_args)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1406, in __init__
    super(HTTPSConnection, self).__init__(host, port, timeout,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 856, in __init__
    (self.host, self.port) = self._get_hostport(host, port)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 899, in _get_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
http.client.InvalidURL: nonnumeric port: '[email protected]'

I'm assuming its because of the colon between '78d32f2c60e08a06ef4438996e77f198' and '[email protected]/admin/api/2023-10/orders.json' but I'm not sure how to get around it.

Thanks

I'm unable to use 'import requests' because IBM code engine won't compile with it.

0

There are 0 best solutions below