简体   繁体   中英

How to get Candy machine v2 ID from a minting site using Python

I'm trying to get the candy machine from any website (or at least most of them). I get the DOM from the website and got the script (where I've discovered there's 'REACT_APP_CANDY_MACHINE_ID' that it's value is the cmid). But I don't know how to read it from Python, I got the script code as string with a GET from the site and soup . I've been looking to iterate through the script and somehow get the variable value but I think it shouldn't be done like this.

 import requests from bs4 import BeautifulSoup as bs from urllib.parse import urljoin session = requests.Session() session.headers["User-Agent"] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36" # the first link I saw with CMv2 url = 'https://lazy-alpha.vercel.app/' html = session.get(url).content soup = bs(html, "html.parser") script_files = [] for script in soup.find_all("script"): if script.attrs.get("src"): script_url = urljoin(url, script.attrs.get("src")) script_files.append(script_url) with open("javascript_files.txt", "w") as f: rsp = requests.get(script_files[0]).text #just checking if I'm going crazy or not yet if 'REACT_APP_CANDY_MACHINE_ID' in rsp: print('Exists')

I've been trying for a while, just in case there's something weird on the code, it's just to make things a little more clear for you. Thanks in advance:)

REACT_APP_CANDY_MACHINE_ID usually comes from the ENV file So i don't think you would be able to get that but if you can somehow get the RPC requests that the Website is sending for fetching CM Data then you can do the same and get the CM data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM