Mar-04-2022, 04:39 PM
Quote:Hello,
I'm trying to extract the assets(ADAUSD,BTCUSD,DOGEUSD,DOTUSD,ETHUSD,LTCUSD,SHIBUSD,XMRUSD,XRPUSD,SOLUSD) part of the following url using urllib.parse, but I got this error:
Does anybody can help me please?
Regards!
import urllib.parse req = requests.get('https://api.kraken.com/0/public/Ticker?pair=ADAUSD,BTCUSD,DOGEUSD,DOTUSD,ETHUSD,LTCUSD,SHIBUSD,XMRUSD,XRPUSD,SOLUSD') parsed = urllib.parse.urlsplit(req) print("{}?{}".format(parsed.path.split("/")[-1], parsed.query))
Error:Traceback (most recent call last):
File "c:\Users\Orlando\Documents\Chile\Kraken\get_tickerinfoSPT.py", line 19, in <module>
parsed = urllib.parse.urlsplit(req.request)
File "C:\Users\Orlando\AppData\Local\Programs\Python\Python310\lib\urllib\parse.py", line 458, in urlsplit
url, scheme, _coerce_result = _coerce_args(url, scheme)
return _decode_args(args) + (_encode_result,)
File "C:\Users\Orlando\AppData\Local\Programs\Python\Python310\lib\urllib\parse.py", line 112, in _decode_args
return tuple(x.decode(encoding, errors) if x else '' for x in args)
File "C:\Users\Orlando\AppData\Local\Programs\Python\Python310\lib\urllib\parse.py", line 112, in <genexpr>
return tuple(x.decode(encoding, errors) if x else '' for x in args)
AttributeError: 'PreparedRequest' object has no attribute 'decode'
PS C:\Users\Orlando\Documents\Chile\Kraken> ^C
PS C:\Users\Orlando\Documents\Chile\Kraken> & C:/Users/Orlando/AppData/Local/Programs/Python/Python310/python.exe c:/Users/Orlando/Documents/Chile/Kraken/get_tickerinfoSPT.py
Traceback (most recent call last):
File "c:\Users\Orlando\Documents\Chile\Kraken\get_tickerinfoSPT.py", line 19, in <module>
o = urllib.parse.urlparse(req)
File "C:\Users\Orlando\AppData\Local\Programs\Python\Python310\lib\urllib\parse.py", line 392, in urlparse
File "C:\Users\Orlando\AppData\Local\Programs\Python\Python310\lib\urllib\parse.py", line 128, in _coerce_args
return _decode_args(args) + (_encode_result,)
File "C:\Users\Orlando\AppData\Local\Programs\Python\Python310\lib\urllib\parse.py", line 112, in _decode_args
return tuple(x.decode(encoding, errors) if x else '' for x in args)
File "C:\Users\Orlando\AppData\Local\Programs\Python\Python310\lib\urllib\parse.py", line 112, in <genexpr>
return tuple(x.decode(encoding, errors) if x else '' for x in args)
AttributeError: 'Response' object has no attribute 'decode'
PS C:\Users\Orlando\Documents\Chile\Kraken> & C:/Users/Orlando/AppData/Local/Programs/Python/Python310/python.exe c:/Users/Orlando/Documents/Chile/Kraken/get_tickerinfoSPT.py
Traceback (most recent call last):
File "c:\Users\Orlando\Documents\Chile\Kraken\get_tickerinfoSPT.py", line 19, in <module>
o = urllib.parse.urlparse(req)
PS C:\Users\Orlando\Documents\Chile\Kraken> & C:/Users/Orlando/AppData/Local/Programs/Python/Python310/python.exe c:/Users/Orlando/Documents/Chile/Kraken/get_tickerinfoSPT.py
Traceback (most recent call last):
File "c:\Users\Orlando\Documents\Chile\Kraken\get_tickerinfoSPT.py", line 19, in <module>
parsed = urllib.parse.urlsplit(req)
File "C:\Users\Orlando\AppData\Local\Programs\Python\Python310\lib\urllib\parse.py", line 458, in urlsplit
url, scheme, _coerce_result = _coerce_args(url, scheme)
File "C:\Users\Orlando\AppData\Local\Programs\Python\Python310\lib\urllib\parse.py", line 128, in _coerce_args
return _decode_args(args) + (_encode_result,)
File "C:\Users\Orlando\AppData\Local\Programs\Python\Python310\lib\urllib\parse.py", line 112, in _decode_args
return tuple(x.decode(encoding, errors) if x else '' for x in args)
File "C:\Users\Orlando\AppData\Local\Programs\Python\Python310\lib\urllib\parse.py", line 112, in <genexpr>
return tuple(x.decode(encoding, errors) if x else '' for x in args)
AttributeError: 'Response' object has no attribute 'decode'