幫你省時省力!批量上傳多張圖片到OPENSEA(一) | python自動處裡大量圖片上傳 | 匯出 chrome extensions to crx + pem金鑰 | Bulk NFT uploader to OpenSea
在 chrome 上安裝 Metamask
把瀏覽器內特定的擴充功能匯出、封裝成 .crx 檔案,
同時會有一把用於簽章的 .pem 金鑰檔案
前往 chrome://extensions/
將右上角的「開發人員模式」打開,
就能看到每個擴充功能的 ID,先把你要備份的外掛編號記住。
開啟檔案總管,在上方路徑輸入:
C:\Users\{UserName}\AppData\Local\Google\Chrome\User Data\Default\Extensions
記得將 UserName 改成你的使用者名稱,
這樣就能看到所有已安裝的擴充功能資料夾
貼上面找到的外掛路徑後點擊封裝擴充功能
成功後會產出.crx 跟 .pem 金鑰
如果顯示指定擴充功能已有私密金鑰,請使用該金鑰,
或先將它刪除,或是類似無法匯出外掛的問題,
通常是貼上的外掛路徑錯誤,
記得要切換進去版本號目錄,再把路徑完整複製下來
成功後會產出.crx 跟 .pem 金鑰
如果顯示指定擴充功能已有私密金鑰,請使用該金鑰,
或先將它刪除,或是類似無法匯出外掛的問題,
通常是貼上的外掛路徑錯誤,
記得要切換進去版本號目錄,再把路徑完整複製下來
撰寫如下 python 供之後進行 metamask 導入webdriver
把PHASE、PASSWORD取代成你自己的
把PHASE、PASSWORD取代成你自己的
為了文章排版code有折行的地方再自行調整一下囉
metamask_connector.py:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time
EXTENSION_PATH = r"C:\Users\... Data\Default\Extensions.../10.8.1_0.crx"
opt = webdriver.ChromeOptions()
opt.add_extension(EXTENSION_PATH)
service_chromedriver = Service("./chromedriver.exe")
driver = webdriver.Chrome(service=service_chromedriver, options=opt)
def meta_mask_navigate(driver):
SECRET_RECOVERY_PHRASE = 'YOUR SECRET_RECOVERY_PHRASE'
NEW_PASSWORD = 'YOUR NEW_PASSWORD'
driver.switch_to.window(driver.window_handles[0])
time.sleep(1)
driver.find_element(By.CLASS_NAME, "first-time-flow__button").click()
time.sleep(1)
driver.find_element(By.XPATH, "//button [text()='匯入錢包']").click()
time.sleep(1)
driver.find_element(By.XPATH, "//button [text()='I Agree']").click()
time.sleep(1)
inputs = driver.find_elements(By.XPATH, '//input')
inputs[0].send_keys(SECRET_RECOVERY_PHRASE)
inputs[1].send_keys(NEW_PASSWORD)
inputs[2].send_keys(NEW_PASSWORD)
checkbox_list = driver.find_elements(By.CLASS_NAME,
"first-time-flow__checkbox-label")
checkbox_list[1].click()
time.sleep(1)
driver.find_element(By.XPATH, "//button [text()='匯入']").click()
time.sleep(5)
driver.find_element(By.XPATH, "//button [text()='都完成了']").click()
time.sleep(1)
def get_driver():
return driver
STEP.3 OPENSEA端
- 創建一個 opensea 帳戶
- 將 metamask 錢包連接到 opensea
- 創建集合名稱 https://opensea.io/collections
操作opensea上傳
將collection網址、圖片路徑取代成自己的
sleep time 依網速、機子狀態調成適合自己的
我這是調得很慢 求穩不求快
將collection網址、圖片路徑取代成自己的
sleep time 依網速、機子狀態調成適合自己的
我這是調得很慢 求穩不求快
opensea_uploader.py:
import time
from selenium.webdriver.common.by import By
import metamask_connector
import os
from pathlib import Path
metamask_connector.meta_mask_navigate()
driver = metamask_connector.get_driver()
driver.execute_script(
'window.open("https://opensea.io/collection/taiwan-gd/assets/create","_blank")')
time.sleep(1)
print(driver.window_handles)
driver.switch_to.window(driver.window_handles[2])
print(driver.title)
time.sleep(1)
driver.find_element(By.CLASS_NAME, "Navbar--brand").click()
time.sleep(1)
driver.back()
time.sleep(1)
driver.find_element(By.XPATH, "//span [text()='MetaMask']").click()
time.sleep(1)
print(driver.window_handles)
driver.switch_to.window(driver.window_handles[3])
time.sleep(3)
driver.find_element(By.CLASS_NAME, "btn-primary").click()
time.sleep(3)
driver.find_element(By.CLASS_NAME, "btn-primary").click()
time.sleep(10)
print(driver.window_handles)
driver.find_element(By.CLASS_NAME, "btn-primary").click()
time.sleep(5)
driver.switch_to.window(driver.window_handles[2])
# get the path/directory
folder_dir = "D:\j\opensea_python_upload\TAIWAN_GD"
description= """TaiwanGD is a fluffy and inedible NFT project.
The project will donate 30%~50% of the profit to animal
protection-related public welfare groups.The rest will be the fuel
to grow the community and help more animals. To help more homeless cats
and dogs find shelter and food."""
if not os.path.exists(folder_dir + '/uploaded'):
os.mkdir(folder_dir + '/uploaded')
time.sleep(5)
for images in os.listdir(folder_dir):
# check if the image ends with png
if (images.endswith(".png")):
print(images)
inputs = driver.find_elements(By.XPATH, '//input')
inputs[1].send_keys(folder_dir + '/' + images)
inputs[2].send_keys(images.replace(".png", "") )
textareas = driver.find_elements(By.XPATH, '//textarea')
textareas[0].send_keys(description)
time.sleep(1)
driver.find_element(By.XPATH, "//button [text()='Create']").click()
time.sleep(20)
driver.find_element(By.XPATH, "//i [text()='close']").click()
Path(folder_dir + '/' + images).rename(folder_dir + '/uploaded/' + images)
time.sleep(10)
driver.execute_script(
'window.open("https://opensea.io/collection/taiwan-gd
/assets/create","_self")')
會將目標資料夾的圖片逐一上傳
已上傳的圖片會被移入uploaded
推薦文章:
EBISU'S BAY 介紹:
幣刷神卡CROYTO.COM 註冊教學:
幣安BINANCE教學:
MAX教學: