0

He creado un programa simple que abre una nueva pestaña en mi navegador actual cuando el usuario clickea el botón Open OpenSea Tab, aquí está el código:

import tkinter as tk 
import webbrowser


root = tk.Tk() #create a GUI element
root.geometry('500x400') #resolution
root.title("Bulkdozer") #Name of this program
root.attributes('-topmost', True) #keep the program's window top-most

def open_chrome_profile():
    webbrowser.open_new_tab('https://opensea.io/asset/create') #open a new tab using user's default browser
   

#####BUTTON ZONE#######
open_browser = tk.Button(root, width=20,  text="Open OpenSea Tab", command=open_chrome_profile) #executes the function when clicked
open_browser.grid(row=22, column=1) #give some specifications
#####BUTTON ZONE END#######
root.mainloop()

Demostración de la GUI:

GUI

Resultado después de clickear el botón "Open OpenSea Tab": OpenSea

Hasta ahora funciona de maravilla, pero sucede que quiero hacer que este programa interactue con la pestaña de OpenSea, especificamenmte para evaluar sí esta página de OpenSea le solicita al usuario conectar una billetera o no, yo sé que puedo usar la librería de Selenium para eso, y de hecho, intenté primero hacer que este programa abriera una nueva ventana en mi navegador predeterminado usando el siguiente código:

import tkinter as tk 
#from tkinter import filedialog
#import webbrowser
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()

chrome_options.add_argument("--user-data-dir="+r"C:\Users\ResetStoreX\AppData\Local\BraveSoftware\Brave-Browser\User Data\Default") # change to profile path
chrome_options.add_argument('--profile-directory='+'Default')

driver = webdriver.Chrome(executable_path="C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe", chrome_options=chrome_options) # change the executable_path too

root = tk.Tk() #create a GUI element
root.geometry('500x400') #resolution
root.title("Bulkdozer") #Name of this program
root.attributes('-topmost', True) #keep the program's window top-most

def open_chrome_profile():
    driver.ExecuteScript("window.open('your URL', '_blank');") #open a new tab using user's default browser
   

#####BUTTON ZONE#######
open_browser = tk.Button(root, width=20,  text="Open OpenSea Tab", command=open_chrome_profile) #executes the function when clicked
open_browser.grid(row=22, column=1) #give some visual specifications for the button
#####BUTTON ZONE END#######
root.mainloop()

Sin embargo, arrojó los siguientes errores:

C:\Users\ResetStoreX\Pictures\Cryptobote\Cryptobote NFTs\Crypto Cangrejos\bulk masive\bulk-dozer.py:19: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
driver = webdriver.Chrome(executable_path="C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe", chrome_options=chrome_options) # change the executable_path too C:\Users\ResetStoreX\Pictures\Cryptobote\Cryptobote NFTs\Crypto Cangrejos\bulk masive\bulk-dozer.py:19: DeprecationWarning: use options instead of chrome_options driver = webdriver.Chrome(executable_path="C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe", chrome_options=chrome_options) # change the executable_path too Traceback (most recent call last):

File "C:\Users\ResetStoreX\miniconda3\envs\spyder-env\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start self.process = subprocess.Popen(cmd, env=self.env,

File "C:\Users\ResetStoreX\miniconda3\envs\spyder-env\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in init super(SubprocessPopen, self).init(*args, **kwargs)

File "C:\Users\ResetStoreX\miniconda3\envs\spyder-env\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds,

File "C:\Users\ResetStoreX\miniconda3\envs\spyder-env\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args,

FileNotFoundError: [WinError 2] El sistema no puede encontrar el archivo especificado

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\ResetStoreX\Pictures\Cryptobote\Cryptobote NFTs\Crypto Cangrejos\bulk masive\bulk-dozer.py", line 19, in driver = webdriver.Chrome(executable_path="C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe", chrome_options=chrome_options) # change the executable_path too

File "C:\Users\ResetStoreX\miniconda3\envs\spyder-env\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in init super(WebDriver, self).init(DesiredCapabilities.CHROME['browserName'], "goog",

File "C:\Users\ResetStoreX\miniconda3\envs\spyder-env\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 90, in init self.service.start()

File "C:\Users\ResetStoreX\miniconda3\envs\spyder-env\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start raise WebDriverException(

WebDriverException: 'Applicatiorave.exe' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home

Entiendo que terminé rompiendo mi programa muy mal, y me gustaría saber ¿por qué pasó?

O sí hay una forma más simple de interactuar con la pestaña de OpenSea usando el código inicial, soy todo oídos...

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.