Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

# Catch JSON-related errors and raise as requests.JSONDecodeError #206

Open
JoshuaChung93 opened this issue Mar 6, 2024 · 1 comment
Open

Comments

@JoshuaChung93
Copy link

안녕하세요, BTC/USD 데이터를 가져오는 도중 아래와 같은 에러가 뜹니다.


JSONDecodeError Traceback (most recent call last)
File ~/opt/anaconda3/lib/python3.9/site-packages/requests/models.py:910, in Response.json(self, **kwargs)
909 try:
--> 910 return complexjson.loads(self.text, **kwargs)
911 except JSONDecodeError as e:
912 # Catch JSON-related errors and raise as requests.JSONDecodeError
913 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError

File ~/opt/anaconda3/lib/python3.9/json/init.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
343 if (cls is None and object_hook is None and
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:

File ~/opt/anaconda3/lib/python3.9/json/decoder.py:337, in JSONDecoder.decode(self, s, _w)
333 """Return the Python representation of s (a str instance
334 containing a JSON document).
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()

File ~/opt/anaconda3/lib/python3.9/json/decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
...

<script>(function(){var js = "window['__CF$cv$params']={r:'86020eed7df93170',t:'MTcwOTcyNTA5NC4wMTkwMDA='};_cpo=document.createElement('script');_cpo.nonce='',_cpo.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js',document.getElementsByTagName('head')[0].appendChild(_cpo);";var _0xh = document.createElement('iframe');_0xh.height = 1;_0xh.width = 1;_0xh.style.position = 'absolute';_0xh.style.top = 0;_0xh.style.left = 0;_0xh.style.border = 'none';_0xh.style.visibility = 'hidden';document.body.appendChild(_0xh);function handler() {var _0xi = _0xh.contentDocument || _0xh.contentWindow.document;if (_0xi) {var _0xj = _0xi.createElement('script');_0xj.innerHTML = js;_0xi.getElementsByTagName('head')[0].appendChild(_0xj);}}if (document.readyState !== 'loading') {handler();} else if (window.addEventListener) {document.addEventListener('DOMContentLoaded', handler);} else {var prev = document.onreadystatechange || function () {};document.onreadystatechange = function (e) {prev(e);if (document.readyState !== 'loading') {document.onreadystatechange = prev;handler();}};}})();</script><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" data-cf-beacon='{"rayId":"86020eed7df93170","b":1,"version":"2024.2.4","token":"00ab903b5e184b1a9d53b0a7a5085300"}' crossorigin="anonymous"></script> : 0
@FinanceData
Copy link
Owner

현재 잘 수행 됩니다. 로컬PC와 Colab에서 모두 잘 수행됩니다.

import FinanceDataReader as fdr 

df = fdr.DataReader('BTC/USD', '2020')
df
                    Open          High           Low         Close     Adj Close        Volume
Date
2020-01-01   7194.892090   7254.330566   7174.944336   7200.174316   7200.174316  1.856566e+10
2020-01-02   7202.551270   7212.155273   6935.270020   6985.470215   6985.470215  2.080208e+10
2020-01-03   6984.428711   7413.715332   6914.996094   7344.884277   7344.884277  2.811148e+10
2020-01-04   7345.375488   7427.385742   7309.514160   7410.656738   7410.656738  1.844427e+10
2020-01-05   7410.451660   7544.497070   7400.535645   7411.317383   7411.317383  1.972507e+10
...                  ...           ...           ...           ...           ...           ...
2024-03-05  68341.054688  69170.625000  59323.910156  63801.199219  63801.199219  1.028029e+11
2024-03-06  63776.050781  67637.929688  62848.671875  66106.804688  66106.804688  6.875023e+10
2024-03-07  66099.742188  68029.921875  65655.531250  66925.484375  66925.484375  4.698954e+10
2024-03-08           NaN           NaN           NaN           NaN           NaN           NaN
2024-03-09  68284.125000  68380.492188  68101.031250  68281.414063  68281.414063  5.867976e+10

[1530 rows x 6 columns]

일시적인 현상이거나 과도한 반복요청으로 문제가 발생했을 수 도 있습니다.
다시 수행해 보시고 동일한 문제가 계속 발생하면 사용하신 코드와 환경에 대해 조금 더 상세하게 알려주시면 감사합니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants