Created
May 7, 2023 22:24
-
-
Save Goatghosts/a5c8d2335af7a68fcf477166478920bd to your computer and use it in GitHub Desktop.
May? Time to look for shitcoins. Edit your own filters. I don't give a shit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
from bs4 import BeautifulSoup | |
def parse(pages): | |
output = [] | |
offset = 1 | |
for _ in range(pages): | |
link = f"https://api.coinmarketcap.com/dexer/v3/platformpage/pair-pages?platform-id=1&dexer-id=1069&" \ | |
f"sort-field=txs24h&operation=next&desc=true&offset={offset}" | |
tokens_data = requests.get(link).json() | |
for i, item in enumerate(tokens_data['data']['pageList']): | |
try: | |
token_name = item["baseTokenSymbol"] | |
pair_address = item["pairContractAddress"] | |
fdv = float(item["fdv"]) | |
liquidity = float(item["liquidity"]) | |
fdvRatio = liquidity / fdv | |
if fdvRatio < 0.1: | |
print(f"Index: {i + offset} | Token: {token_name} | fdvRatio: {fdvRatio} | Skip") | |
continue | |
elif fdv > 1500000: | |
print(f"Index: {i + offset} | Token: {token_name} | fdv: {fdv} | Skip") | |
continue | |
elif liquidity < 3000: | |
print(f"Index: {i + offset} | Token: {token_name} | liquidity: {liquidity} | Skip") | |
continue | |
token_url = f"https://coinmarketcap.com/dexscan/ethereum/{pair_address}" | |
token_data = requests.get(token_url).text | |
soup = BeautifulSoup(token_data, "html.parser") | |
risks = soup.find('span', class_='sc-4984dd93-0 cEFVjA security-statistics').text.strip() | |
warning = soup.find('span', class_='sc-4984dd93-0 gmuHHd security-statistics').text.strip() | |
if risks != '0 risks': | |
print(f"Index: {i + offset} | Token: {token_name} | risks: {risks} | Skip") | |
continue | |
print(f"Index: {i + offset} | Token {token_name}") | |
table = soup.find('div', class_='dexscan-detail-stats-section') | |
td = table.find_all('span', class_='box-number') | |
output.append({ | |
'index': i + offset, | |
"url": token_url, | |
"name:": token_name, | |
"price": item["priceUsd"], | |
"change1h": float(item["basePrice1h"]), | |
"change24h": float(item["baseChange24h"]), | |
"txns": int(item["txns24h"]), | |
"volume": item["volumeUsd24h"], | |
"liquidity": liquidity, | |
"fdv": fdv, | |
"fdvRatio:": fdvRatio, | |
"total_supply": td[4].text.strip(), | |
"holders": td[3].text.strip(), | |
"created": td[11].text.strip(), | |
"risks": risks, | |
"warning": warning, | |
}) | |
except Exception as ex: | |
print("Exception", ex) | |
continue | |
offset += 50 | |
with open('coinmarketcap.json', 'w', encoding='utf-8') as file: | |
json.dump(output, file, indent=2, ensure_ascii=True) | |
if __name__ == '__main__': | |
parse(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment