Skip to content

Commit

Permalink
Merge branch 'master' into multiple-formats
Browse files Browse the repository at this point in the history
  • Loading branch information
guptarohit committed Jan 12, 2019
2 parents 529312d + a5941f1 commit 9a0c629
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
18 changes: 9 additions & 9 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cryptocmd/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.2"
__version__ = "0.4.4"
13 changes: 8 additions & 5 deletions cryptocmd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@ def get_coin_id(coin_code):
"""

try:
url = "https://api.coinmarketcap.com/v1/ticker/?limit=0"
url = "https://coinmarketcap.com/all/views/all/"

json_resp = get_url_data(url).json()
html = get_url_data(url).text
raw_data = pq(html)

coin_code = coin_code.upper()

for coin in json_resp:
if coin["symbol"] == coin_code:
return coin["id"]
for _row in raw_data("tr")[1:]:
symbol = _row.cssselect("td.text-left.col-symbol")[0].text_content()
coin_id = _row.values()[0].split("id-")[1]
if symbol == coin_code:
return coin_id
raise InvalidCoinCode('This coin code is unavailable on "coinmarketcap.com"')
except Exception as e:
raise e
Expand Down

0 comments on commit 9a0c629

Please sign in to comment.