-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspider.py
More file actions
55 lines (45 loc) · 1.82 KB
/
spider.py
File metadata and controls
55 lines (45 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import requests
import json
import yaml
try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
from yaml import Loader, Dumper
from log4py import Logger
Logger.set_level("INFO")
log = Logger.get_logger(__name__)
f = open(r'./config.yml')
cfg = yaml.load(f, Loader=Loader)
COIN_MARKET_API_KEY = cfg['coinmarketcap_api']
print(COIN_MARKET_API_KEY)
def getMarketPrice():
currentBABYPrice = 0
currentMILKPrice = 0
response = requests.get(
'https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest',
params={'symbol': 'BABY,MILK'},
headers={'Accepts': 'application/json', 'X-CMC_PRO_API_KEY': COIN_MARKET_API_KEY},
timeout=1
)
dicts = json.loads(response.text)
if dicts['status']['error_code'] == 0:
currentBABYPrice = dicts['data']['BABY']['quote']['USD']['price']
currentMILKPrice = dicts['data']['MILK']['quote']['USD']['price']
log.info("BABY : " + str(currentBABYPrice) + " USDT")
log.info("MILK : " + str(currentMILKPrice) + " USDT")
return currentBABYPrice, currentMILKPrice
def getMarketList():
response = requests.get('https://service.thecryptoyou.io/nft/market/list', timeout=1)
dicts = json.loads(response.text)
sortedList = []
if dicts['massage'] == 'Success':
sortedList = sorted(dicts['data'], key=lambda i: i['createDate'], reverse=True)
return sortedList
def getLeaderInfo():
response = requests.post('https://graph.babyswap.info/subgraphs/name/bscmainbabyswap/leaderboard1',
timeout=1,
headers={
'Accepts': 'application/json',
'Content-Type': 'application/json',
'origin': 'https://thecryptoyou.io'})
print(response.text)