Python:
# 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)
#path = '/usr/local/bin/chromedriver'
#driver = webdriver.Chrome(executable_path=path)
chain = 'matic' # Change for other chains, but if you're using other chains just use the API instead
# Pull this from the URL of your collection
collection_address = 'address'
price = '0.002' # 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(500): # 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(500):
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")