You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Michael, how are you? When I run the .exe of my script, after some time (about 60 minutes), the script stops unexpectedly. The script opens 3 tabs with 3 links and switches between tabs to check if a specific element is present on the webpage, with a timeout of 0.1 seconds:
This is the error:
What could be causing the script to freeze after a while? Could it be that switching tabs too quickly is causing the issue? How can I optimize the code?
I look forward to your response, thank you in advance. I really appreciate your work.
Here is the complete code:
with SB(is_mobile=True,headless2=False,user_data_dir=user_data_dir,chromium_arg=chromium_arg) as sb:
sb.driver.maximize_window()
for url in urls:
sb.execute_script(f"window.open('{url}');")
time.sleep(1)
ventanas = sb.driver.window_handles
lista_buenas = []
#This is a loop to check on each tab that no captcha has appeared on the webpage I am visiting.
while True:
if len(lista_buenas) == len(urls):
break
for x in range(1,len(ventanas)):
if x not in lista_buenas:
sb.switch_to_window(sb.driver.window_handles[x])
try:
sb.driver.switch_to_frame("iframe[sandbox='allow-scripts allow-same-origin allow-forms']")
sb.refresh()
except:
nombrito = sb.get_text("//header[@data-pw-test-id='event-header']//h1/span")
print(f"(+) Todo bien en {nombrito}")
lista_buenas.append(x)
else:
continue
sb.switch_to_window(sb.driver.window_handles[0])
sb.driver.close()
time.sleep(1)
nuevas = sb.driver.window_handles
#this is the main code
while True:
try:
for x in range(len(nuevas)):
sb.switch_to_window(nuevas[x])
nombre_evento = sb.get_text("//header[@data-pw-test-id='event-header']//h1/span")
sb.click("//button[@data-button-tracking-id='toggle-tickets-modal-open']",scroll=False)
try:
sb.switch_to_frame("//iframe[@id='#tickets-iframe-s']")
except:
print("(-) HA TARDADO EN CARGAR...")
pass
try:
sb.assert_element_present("//li[@class='onsale but']//div[contains(text(),'32,80 €')]",timeout=0.1)
mensaje = f"Entrada encontrada para el evento: {nombre_evento}"
telegram(mensaje)
sb.switch_to_default_content()
sb.click('//button[@data-button-tracking-id="toggle-tickets-modal-closed"]')
except:
sb.switch_to_default_content()
sb.click('//button[@data-button-tracking-id="toggle-tickets-modal-closed"]')
continue
except KeyboardInterrupt:
print("Saliendo...")
break
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi Michael, how are you? When I run the .exe of my script, after some time (about 60 minutes), the script stops unexpectedly. The script opens 3 tabs with 3 links and switches between tabs to check if a specific element is present on the webpage, with a timeout of 0.1 seconds:
This is the error:
What could be causing the script to freeze after a while? Could it be that switching tabs too quickly is causing the issue? How can I optimize the code?
I look forward to your response, thank you in advance. I really appreciate your work.
Here is the complete code:
Beta Was this translation helpful? Give feedback.
All reactions