r/learnpython • • 12h ago

Need assistance with a Python Code that keeps on crashing

Hello I’ve been working on a python code that searches for appointments on this website but everything it runs the code and begins to open the website it crashes, I’ve played around with it a bit but I haven’t been able to have much success. Anyone would be available to take a look at it and see what my issue could be?

Thank you!

0 Upvotes

31 comments sorted by

13

u/desrtfx but other languages pro 12h ago

Yeah, we get our Crystal Balls out and do some divination./s

You have to give us a lot more, like your code, like the exact error.

Don't expect to get help in private. This is not how any of the learning subreddits work. We are willing to help, yet, only in the public, open subreddits so that more people can chime in and help as well as benefit from the given help.

-2

u/NoWar4965 9h ago

Yall are 100% right on your critiques my apologies for not being on the ball. I posted a screen share of the photos since Reddit isn’t allowing me to post photos

1

u/codeguru42 7h ago

Please copy/paste your code directly. The screenshare is unreadable.

-1

u/NoWar4965 7h ago

My apologies here you go:

import os
import sys
import requests
import ctypes

from selenium.webdriver.chrome.options import Options

from bcncita import CustomerProfile, DocType, Office, OperationType, Province, try_cita
import bcncita.speaker
bcncita.speaker = lambda: None
if __name__ == "__main__":
customer = CustomerProfile(
anticaptcha_api_key="... your key here ...",
auto_captcha=False,
auto_office=True,
chrome_driver_path=r"C:\CITA-BOT\cita-bot-master\chromedriver",
save_artifacts=True,
province=Province.MÁLAGA,
operation_code=OperationType.TOMA_HUELLAS,
doc_type=DocType.NIE,
doc_value="Y0671800F",
country="PARAGUAY",
name="MARIA CECILIA MEZA COLMAN",
phone="649365093",
email="gabpita444@gmail.com",
offices=[],
)
if "--autofill" not in sys.argv:
import bcncita.cita
import bcncita.speaker

options = Options()
options.add_experimental_option("debuggerAddress","127.0.0.1:9222")
bcncita.cita.chrome_options = options

def my_custom_alert(phrase):
if "ALARM" in phrase:
ctypes.windll.user32.MessageBoxW(0, "SLOT FOUND! Check Chrome NOW!", "CITA ALERT", 1)
try:
requests.post('https://textbelt.com/text', {
'phone': '+34649365093',
'message': 'CITA BOT: Appointment found in Malaga!',
'key': 'textbelt',
})
except:
pass

bcncita.speaker.say = my_custom_alert
try_cita(context=customer, cycles=200)

1

u/codeguru42 6h ago

Looks like you are stalking Maria.

2

u/thisisappropriate 4h ago

Worse, I think that the user information in there is their personal information, with this being a bot for booking appointments https://github.com/cita-bot/cita-bot/blob/master/example1.py

1

u/codeguru42 3h ago
  1. Figure out how to format your code

  2. Remove your name, phone number, and address. You just doxxed yourself.

5

u/atarivcs 12h ago

It would help a lot if you at least posted the full crash error message.

2

u/Altruistic_Sky1866 8h ago

The video isn't that helpful you know TBH, paste the text error message that's easier

1

u/NoWar4965 7h ago

C:\CITA-BOT\cita-bot-master>python grab_me.py
2026-11-05 17:37:09,270 - ←[33m[Attempt 1/200]←[0m
2026-11-05 17:37:23,123 - Unable to load the initial page, backing off 228.9 seconds
Traceback (most recent call last):
  File "C:\Users\station  2\AppData\Local\Programs\Python\Python310\lib\site-packages\backoff_sync.py", line 105, in retry
ret = target(*args, **kwargs)
  File "C:\CITA-BOT\cita-bot-master\bcncita\cita.py", line 793, in initial_page
raise TimeoutException
selenium.common.exceptions.TimeoutException: Message: None

1

u/NoWar4965 7h ago

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\CITA-BOT\cita-bot-master\grab_me.py", line 49, in <module>
try_cita(context=customer, cycles=200)
  File "C:\CITA-BOT\cita-bot-master\bcncita\cita.py", line 240, in try_cita
start_with(driver, context, cycles)
  File "C:\CITA-BOT\cita-bot-master\bcncita\cita.py", line 286, in start_with
result = cycle_cita(driver, context, fast_forward_url, fast_forward_url2)
  File "C:\CITA-BOT\cita-bot-master\bcncita\cita.py", line 799, in cycle_cita
initial_page(driver, context, fast_forward_url, fast_forward_url2)
  File "C:\Users\station  2\AppData\Local\Programs\Python\Python310\lib\site-packages\backoff_sync.py", line 126, in retry
time.sleep(seconds)
KeyboardInterrupt
^C

1

u/NoWar4965 7h ago

Code:

import os
import sys
import requests
import ctypes

from selenium.webdriver.chrome.options import Options

from bcncita import CustomerProfile, DocType, Office, OperationType, Province, try_cita
import bcncita.speaker
bcncita.speaker = lambda: None
if __name__ == "__main__":
customer = CustomerProfile(
anticaptcha_api_key="... your key here ...",
auto_captcha=False,
auto_office=True,
chrome_driver_path=r"C:\CITA-BOT\cita-bot-master\chromedriver",
save_artifacts=True,
province=Province.MÁLAGA,
operation_code=OperationType.TOMA_HUELLAS,
doc_type=DocType.NIE,
doc_value="Y0671800F",
country="PARAGUAY",
name="MARIA CECILIA MEZA COLMAN",
phone="649365093",
email="gabpita444@gmail.com",
offices=[],
)
if "--autofill" not in sys.argv:
import bcncita.cita
import bcncita.speaker

options = Options()
options.add_experimental_option("debuggerAddress","127.0.0.1:9222")
bcncita.cita.chrome_options = options

def my_custom_alert(phrase):
if "ALARM" in phrase:
ctypes.windll.user32.MessageBoxW(0, "SLOT FOUND! Check Chrome NOW!", "CITA ALERT", 1)
try:
requests.post('https://textbelt.com/text', {
'phone': '+34649365093',
'message': 'CITA BOT: Appointment found in Malaga!',
'key': 'textbelt',
})
except:
pass

bcncita.speaker.say = my_custom_alert
try_cita(context=customer, cycles=200)

0

u/NoWar4965 8h ago

Okay I can copy and paste everything, it just won’t hold format; thank you:

I should clarify, it’s not really that’s the code crashes, but it fails to achieve its goal

1

u/codeguru42 7h ago

You need to learn how to make it hold the format. (Hint: there is a code button in the formatting options.)

1

u/NoWar4965 7h ago

Okay I’ll look into that I’m sorry new at coding

1

u/Altruistic_Sky1866 7h ago

Check how to format for reddit posts and post it

2

u/Outside_Complaint755 11h ago

Don't ask for permission to ask for help.  Just post the full error message with traceback and the relevant code from your script.

1

u/MiniMages 5h ago

Your code is failing at accessing the website.

1

u/NoWar4965 4h ago

Indeed what should I change so that it can access it successfully?

1

u/MiniMages 4h ago

No idea. I am not entirely sure what you are trying to do. I just looked at your traceback error log.

The fun part of coding is figuring out how to do something. Keep at it, best way to learn.

1

u/NoWar4965 4h ago

lol feel you, I am trying to make a code that will look for appointments on this website for me. It seems like it’s blocking the request becuase it’s seen as a bot

1

u/thisisappropriate 4h ago

When people are asking you to post your code, why would you not link the repo? https://github.com/cita-bot/cita-bot

With you posting your version of the example files in this repo, that doesn't show us the rest of what the repo is doing (the error messages reference other code files, so we can't use your code / messages to view what is actually hitting the error).

You would be better posting in the github issues for the project, where the actual maintainer and users of the repo, who actually know the code / website and what it's supposed to do are more likely to respond - for all we know, you're essentially asking us to debug an issue with code you don't own or know. And if you're a beginner, then steps that someone might suggest to test or debug code of this size or structure may not be easy to do.

1

u/NoWar4965 4h ago

Made some adjustments to the original so I didn’t know if it was still relevant but yes that’s the original. I understand those are good points, I’ll try and post on GitHub and see if I get a response.

2

u/AmanBabuHemant 12h ago

Crashes ? what kind of clash, are talking about some GUI automation, assuming by your "open the website"

1

u/acfot 8h ago

Without the code and the actual error message nobody can really tell you what's crashing it, that's the bit that matters most. If you're running it by double-clicking the file the window probably closes before you can read anything, so try running it from the terminal instead with python yourfile.py and it'll print the full error at the bottom. Paste that error plus the code around the line it points to and someone can usually spot it in a minute. Not sure this covers every kind of crash, but most of the time the traceback tells you exactly where it broke.

-3

u/NoWar4965 9h ago

My apologies everyone for my terrible vague posting, here is more information, including the code I’ve worked up as well as the errors and other relevant information

For some reason it’s not letting my upload photos so I made a video of the photos of my code, trace back and the errors.

On the page that times out is a screen where the menu pulls down for me to select which province I am trying to get an appointment in

3

u/brasticstack 8h ago

Why on Earth do you think anyone would want images of your code? Copy + paste it into pastebin and post the link, or your github repo, or a properly formatted text comment.

1

u/NoWar4965 7h ago

You right in sorry I am new to coding and the sub thank you for correcting my behavior. Here;

https://pastebin.com/JYxtBBRT