【问题标题】:How to get Candy machine v2 ID from a minting site using Python如何使用 Python 从铸币站点获取 Candy machine v2 ID
【发布时间】:2022-06-11 01:43:02
【问题描述】:

我正在尝试从任何网站(或至少大部分网站)获取糖果机。我从网站上获取了 DOM 并得到了脚本(我发现有'REACT_APP_CANDY_MACHINE_ID',它的值是 cmid)。但我不知道如何从 Python 中读取它,我从网站和soup 获得了带有 GET 的字符串作为脚本代码。我一直在寻找遍历脚本并以某种方式获取变量值,但我认为不应该这样做。

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')

我已经尝试了一段时间,以防万一代码有什么奇怪的地方,只是为了让你更清楚一点。在此先感谢:)

【问题讨论】:

    标签: python solana metaplex


    【解决方案1】:

    REACT_APP_CANDY_MACHINE_ID 通常来自 ENV 文件所以我认为您无法获得它,但如果您能以某种方式获得网站为获取 CM 数据而发送的 RPC 请求,那么您可以执行相同操作并获得CM 数据。

    【讨论】:

      猜你喜欢
      • 2022-07-22
      • 2022-10-19
      • 2022-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多