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

Attribut error and JSONDecodeError #3

Open
nathPay opened this issue Dec 17, 2019 · 1 comment
Open

Attribut error and JSONDecodeError #3

nathPay opened this issue Dec 17, 2019 · 1 comment

Comments

@nathPay
Copy link

nathPay commented Dec 17, 2019

Hi,
I'm using Jupyter Notebook to execute the following code:

import json
from nakamoto import SectorNakamoto, Nakamoto
from nakamoto.sector import CustomSector, Client, Geography, Market, Repository

currency = 'ETC'
nakamoto_config = {
    'plot_notebook': True,
    'plot_image_path': 'image.png'
}

market_url = 'https://coinmarketcap.com/currencies/ethereum-classic/#markets'
market = Market(currency, market_url, **nakamoto_config)

client = Client(currency, **nakamoto_config)

The problem is that Market(currency, market_url, **nakamoto_config) throw this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-30-b88230843554> in <module>
     13 
     14 market_url = 'https://coinmarketcap.com/currencies/ethereum-classic/#markets'
---> 15 market = Market(currency, market_url, **nakamoto_config)
     16 
     17 client = Client(currency, **nakamoto_config)

~/anaconda3/lib/python3.7/site-packages/nakamoto/sector/market.py in __init__(self, currency, market_url, **kwargs)
     10         self.type = 'market'
     11         self.market_url = market_url
---> 12         self.generate_market_data()
     13 
     14     def generate_market_data(self):

~/anaconda3/lib/python3.7/site-packages/nakamoto/sector/market.py in generate_market_data(self)
     17         table = r.html.find('#markets-table', first=True)
     18         session.close()
---> 19         market_df = pd.read_html(table.html)[0]
     20         volume_data = market_df['Volume (24h)']
     21         volume_data = volume_data.str.replace('$', '', regex=False)

AttributeError: 'NoneType' object has no attribute 'html'

If I comment the markets lines client throw this error:

---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
<ipython-input-29-34b9cc44f973> in <module>
     15 #market = Market(currency, market_url, **nakamoto_config)
     16 
---> 17 client = Client(currency, **nakamoto_config)

~/anaconda3/lib/python3.7/site-packages/nakamoto/sector/client.py in __init__(self, currency, **kwargs)
     12         ether_test = (self.currency == 'ETC') or (self.currency == 'ETH')
     13         if ether_test:
---> 14             self.generate_evm_client_data()
     15         else:
     16             raise "Node Client only implemented for EVM-based Nodes"

~/anaconda3/lib/python3.7/site-packages/nakamoto/sector/client.py in generate_evm_client_data(self)
     30 
     31         response = requests.get(url)
---> 32         response_hash = json.loads(response.text).get('data')
     33         df = pd.DataFrame.from_dict(response_hash)
     34         client_raw = df.groupby('client').nunique()

~/anaconda3/lib/python3.7/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    346             parse_int is None and parse_float is None and
    347             parse_constant is None and object_pairs_hook is None and not kw):
--> 348         return _default_decoder.decode(s)
    349     if cls is None:
    350         cls = JSONDecoder

~/anaconda3/lib/python3.7/json/decoder.py in decode(self, s, _w)
    335 
    336         """
--> 337         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338         end = _w(s, end).end()
    339         if end != len(s):

~/anaconda3/lib/python3.7/json/decoder.py in raw_decode(self, s, idx)
    353             obj, end = self.scan_once(s, idx)
    354         except StopIteration as err:
--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
    356         return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Do I use it right ? Any Idea about how to solve it ?

@YazzyYaz
Copy link
Collaborator

Thanks for reporting this. I think the bug is because of outdated links. I'll take a look today and debug it

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