diff --git a/cryptocmd/core.py b/cryptocmd/core.py index 546d609..8db0322 100644 --- a/cryptocmd/core.py +++ b/cryptocmd/core.py @@ -93,22 +93,15 @@ def get_data(self, format="", verbose=False, **kwargs): :param kwargs: Optional arguments that data downloader takes. :return: """ - if format: - data = tablib.Dataset() - - if format not in data._formats: - raise tablib.UnsupportedFormat( - "Format {0} cannot be exported.".format(format) - ) self._download_data(**kwargs) - if verbose: print(*self.headers, sep=", ") for row in self.rows: print(*row, sep=", ") elif format: + data = tablib.Dataset() data.headers = self.headers for row in self.rows: data.append(row) diff --git a/cryptocmd/utils.py b/cryptocmd/utils.py index c2d005a..0007131 100644 --- a/cryptocmd/utils.py +++ b/cryptocmd/utils.py @@ -41,10 +41,12 @@ def get_coin_id(coin_code): raw_data = pq(html) coin_code = coin_code.upper() + data_table = raw_data("tbody")[0] - for _row in raw_data("tr")[1:]: - symbol = _row.cssselect("td.text-left.col-symbol")[0].text_content() - coin_id = _row.values()[0][3:] + for _row in data_table.findall("tr"): + symbol = _row.findall("td")[2].text_content() + coin_link = _row.findall("td")[1].find_class("cmc-link")[0] + coin_id = coin_link.values()[0].lstrip("/currencies/")[:-1] if symbol == coin_code: return coin_id raise InvalidCoinCode("'{}' coin code is unavailable on coinmarketcap.com".format(coin_code)) @@ -140,7 +142,7 @@ def extract_data(html): rows = [] - for _row in raw_data("table tbody>tr"): + for _row in raw_data(".cmc-tab-historical-data table tbody>tr"): row = [ _native_type(_replace(col.text_content().strip(), ",-*?")) for col in _row.findall("td")