Browse Source

Added multipage support to mtc api

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

20
crypto51/apis/mtc.py

@ -6,14 +6,18 @@ class MTC:
self._session = HTMLSession()
def get_coins(self):
resp = self._session.get('https://minethecoin.com')
for match in resp.html.find('.mineable'):
symbol = match.find('.coin-name', first=True).attrs['title'].split(' - ')[0]
yield {
'symbol': symbol,
'name': match.find('.coin-name', first=True).attrs['title'].split(' - ')[1],
'link': match.find('.coin-name', first=True).attrs['href']
}
page = 1
while page:
resp = self._session.get('https://minethecoin.com?page={}'.format(page))
for match in resp.html.find('.mineable'):
symbol = match.find('.coin-name', first=True).attrs['title'].split(' - ')[0]
yield {
'symbol': symbol,
'name': match.find('.coin-name', first=True).attrs['title'].split(' - ')[1],
'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):
"""Convert the hash rate string to a h/s hash rate."""

1
dist/.gitignore

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

2
dist/coins/.gitignore

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