Skip to content

Commit 73ca95d

Browse files
committedFeb 13, 2023
fixed NFT_supply
add json to parse total_supply from api
1 parent 3e96174 commit 73ca95d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed
 

‎main.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from multiprocessing import Pool
1414
from argparse import ArgumentParser
1515
import logging
16+
import json
1617

1718
import cloudscraper
1819
import pandas as pd
@@ -109,7 +110,7 @@ def is_nft_suspicious(nft_url):
109110
OPENSEA_BASE_URL = (
110111
"https://opensea.io/assets/ethereum/" # TODO adjust for other blockchains
111112
)
112-
113+
OPENSEA_BASE_API = "https://api.opensea.io/api/v1/asset/"
113114

114115
def list_collection_nfts_urls(collection_address):
115116
"""List all OpenSea URLs of NFTs in a collection
@@ -120,9 +121,15 @@ def list_collection_nfts_urls(collection_address):
120121
Returns:
121122
array: list of the OpenSea URLs of NFTs
122123
"""
124+
link = (OPENSEA_BASE_API + collection_address + "/0/?format=json")
125+
res = scraper.get(link)
126+
parsed = json.loads(res.text)
127+
nft_supply = int(parsed['collection']['stats']['total_supply'])
128+
129+
123130
# ! This is just a mock function. It is to be replaced with a call to the OpenSea API
124131
nft_urls = []
125-
for i in range(0, 1000):
132+
for i in range(0, nft_supply):
126133
nft_urls.append(f"{OPENSEA_BASE_URL}{collection_address}/{i}")
127134
return nft_urls
128135

0 commit comments

Comments
 (0)
Please sign in to comment.