Answer the question
In order to leave comments, you need to log in
What to do with this error?
Here is my code:
import requests
def scrape():
response = requests.get(URL)
response_json = response.json()
return float(response_json["USD"]["last"])
URL = 'https://blockchain.info/ru/ticker'
last_price = None
while True:
latest_price = scrape()
if latest_price != last_price:
print("Последняя цена BTC: ", latest_price)
last_price = latest_price
Traceback (most recent call last):
File "C:\Users\vo171\AppData\Local\Programs\Python\Python39\task.py", line 12, in <module>
latest_price = scrape()
File "C:\Users\vo171\AppData\Local\Programs\Python\Python39\task.py", line 5, in scrape
response_json = response.json()
File "C:\Users\vo171\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 910, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\vo171\AppData\Local\Programs\Python\Python39\lib\site-packages\simplejson\__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "C:\Users\vo171\AppData\Local\Programs\Python\Python39\lib\site-packages\simplejson\decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "C:\Users\vo171\AppData\Local\Programs\Python\Python39\lib\site-packages\simplejson\decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Answer the question
In order to leave comments, you need to log in
Remove "ru" from URL:
>>> URL = 'https://blockchain.info/ticker'
>>> response = requests.get(URL)
>>> response.json()
{'AUD': {'15m': 51425.37, 'last': 51425.37, 'buy': 51425.37, 'sell': 51425.37, 'symbol': 'AUD'}, '...}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question