forked from Vikapobeda2020/Solana-Sniping-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScraper.py
54 lines (37 loc) · 1.56 KB
/
Scraper.py
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
import requests
class Scraper:
def __init__(self, config):
self.config = config
def getCollections(self):
print("Getting all collections from MagicEden.io...")
collections = list()
counter = 0
while True:
response = requests.get(self.baseUrl + f"collections?offset={counter}").json()
if len(response) < 1:
break
for i in range(len(response)):
collections.append({"symbol": response[i]['symbol'], "name": response[i]['name']})
counter += len(response)
print("Done\n")
return collections
def getListing(self, symbol):
print('Getting all the NFT from the marketplace...')
listings = list()
counter = 0
while True:
response = requests.get(self.baseUrl + f'collections/{symbol}/listings?offset={counter}').json()
if len(response) < 1:
break
for i in range(len(response)):
listings.append({'price': response[i]['price'], 'tokenMint': response[i]['tokenMint']})
counter += len(response)
return listings
def getEligibleListings(self, listings):
eligibleListings = list()
listingPrices = list()
for listing in listings:
if listing['price'] <= self.config['willingPrice']:
eligibleListings.append(listing)
listingPrices.append(listing['price'])
return eligibleListings, listingPrices