-
-
Save fellu/b293935d3a8390fbb077b4d7ac881c79 to your computer and use it in GitHub Desktop.
Auto-list NFTs on OpenSea with Browser Automation
This file contains 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
# First install Chrome, and the Selenium driver | |
# Next, download and save the MetaMask CRX (there are plenty of guides on how to do this) | |
from selenium import webdriver | |
from webdriver_manager.chrome import ChromeDriverManager | |
from selenium.webdriver.chrome.options import Options | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.common.keys import Keys | |
import time | |
# The first time you do this, you'll need to connect your metamask wallet | |
# Leave the browser open with only one tab | |
op = Options() | |
op.add_extension('metamask.crx') # <-- route to the CRX file | |
chrome = webdriver.Chrome(ChromeDriverManager().install(), options=op) | |
chain = 'matic' # Change for other chains, but if you're using other chains just use the API instead | |
collection_address = '0x000' # Pull this from the URL of your collection | |
price = '0.0069' # must be a string | |
def list(i): | |
# Main window | |
chrome.switch_to.window(chrome.window_handles[0]) | |
# Go to sale page | |
chrome.get('https://opensea.io/assets/{}/{}/{}/sell'.format(chain, collection_address, i)) | |
# Check that it isn't already for sale - nevermind it just lists it again | |
# Set price | |
for i in range(50): # See if it's there | |
try: | |
chrome.find_element(By.XPATH, '//input[@name="price"]') | |
break | |
except: | |
time.sleep(0.5) | |
chrome.find_element(By.XPATH, '//input[@name="price"]').send_keys(price + Keys.RETURN) | |
# Click sign | |
for i in range(50): | |
try: | |
chrome.find_element(By.XPATH, '//button[text()="Sign"]') | |
break | |
except: | |
time.sleep(0.5) | |
chrome.find_element(By.XPATH, '//button[text()="Sign"]').click() | |
# Switch to new window | |
time.sleep(1) | |
chrome.switch_to.window(chrome.window_handles[1]) | |
# Click sign | |
for i in range(50): | |
try: | |
chrome.find_element(By.XPATH, '//button[text()="Sign"]') | |
break | |
except: | |
time.sleep(0.5) | |
chrome.find_element(By.XPATH, '//button[text()="Sign"]').click() | |
start = int(input("Start index (included): ")) | |
end = int(input("End index (included): ")) | |
for i in range(start, end+1): | |
list(i) | |
print("Ended listing") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And how to set the date and time of the start of sales?