Browse Source

Added multipage support to mtc api

master
Tom Dickman 6 years ago
parent
commit
9e16ae3d98
  1. 6
      crypto51/apis/mtc.py
  2. 1
      dist/.gitignore
  3. 2
      dist/coins/.gitignore

6
crypto51/apis/mtc.py

@ -6,7 +6,9 @@ class MTC:
self._session = HTMLSession() self._session = HTMLSession()
def get_coins(self): def get_coins(self):
resp = self._session.get('https://minethecoin.com') page = 1
while page:
resp = self._session.get('https://minethecoin.com?page={}'.format(page))
for match in resp.html.find('.mineable'): for match in resp.html.find('.mineable'):
symbol = match.find('.coin-name', first=True).attrs['title'].split(' - ')[0] symbol = match.find('.coin-name', first=True).attrs['title'].split(' - ')[0]
yield { yield {
@ -14,6 +16,8 @@ class MTC:
'name': match.find('.coin-name', first=True).attrs['title'].split(' - ')[1], 'name': match.find('.coin-name', first=True).attrs['title'].split(' - ')[1],
'link': match.find('.coin-name', first=True).attrs['href'] 'link': match.find('.coin-name', first=True).attrs['href']
} }
# Check if another page exists
page = None if 'disabled' in resp.html.find('.pagination', first=True).find('.page-item')[-1].attrs['class'] else page + 1
def _get_h_hash_rate(self, text): def _get_h_hash_rate(self, text):
"""Convert the hash rate string to a h/s hash rate.""" """Convert the hash rate string to a h/s hash rate."""

1
dist/.gitignore

@ -1,2 +1,3 @@
* *
!.gitignore !.gitignore
!coins/

2
dist/coins/.gitignore

@ -0,0 +1,2 @@
*
!.gitignore
Loading…
Cancel
Save