This Selenium automatization script helps to catch cita timeslot.
It DOES make a reservation (semi)automatically
...if you set up a Telegram bot and use it for SMS confirmation. Otherwise:
Enable your speakers and wait for "ALARM ALARM ALARM" message :) Next you'll have to confirm an appointment via SMS code.
If you want a support for new procedure or province, open an issue or better a pull request. The following things are fully supported at the moment:
Procedures:
- EXTRANJERIA - SOLICITUD DE AUTORIZACIONES
- POLICIA - RECOGIDA DE TARJETA DE IDENTIDAD DE EXTRANJERO (TIE)
- POLICIA-AUTORIZACIÓN DE REGRESO
- POLICIA-CARTA DE INVITACIÓN
- POLICIA-CERTIFICADO DE REGISTRO DE CIUDADANO DE LA U.E.
- POLICIA-CERTIFICADOS (DE RESIDENCIA, DE NO RESIDENCIA Y DE CONCORDANCIA)
- POLICIA-CERTIFICADOS Y ASIGNACION NIE
- POLICIA-CERTIFICADOS Y ASIGNACION NIE (NO COMUNITARIOS)
- POLICIA-TOMA DE HUELLAS (EXPEDICIÓN DE TARJETA) Y RENOVACIÓN DE TARJETA DE LARGA DURACIÓN
- POLICÍA-EXP.TARJETA ASOCIADA AL ACUERDO DE RETIRADA CIUDADANOS BRITÁNICOS Y SUS FAMILIARES (BREXIT)
Provinces:
- Barcelona
- Santa Cruz de Tenerife
Other provinces are also supported if you leave offices
empty and that way try and get an appointment in a random one, but if you're required to select a specific office (as in case of OperationType.RECOGIDA_DE_TARJETA
), you should figure out office ids for your province from the appropriate page on your own.
-
Install Python 3.8: https://www.python.org/downloads/release/python-385/
-
pip install -r requirements.txt
-
Install Google Chrome.
-
Download chromedriver and put it in the PATH (Python dir from step 1 should work).
-
Get API Key from https://anti-captcha.com ($5 is enough, trust me! :)
-
Copy example file and fill your data, save it as
grab_me.py
. -
Run
python grab_me.py
, follow the voice instructions.
-
example1.py
— Recogida de tarjeta -
example2.py
— Toma de huellas -
example3.py
— Solicitud de autorizaciones
@dataclass
class CustomerProfile:
anticaptcha_api_key: Optional[str] = None
auto_captcha: bool = True
auto_office: bool = True
chrome_driver_path: str = None
chrome_profile_name: Optional[str] = None
chrome_profile_path: Optional[str] = None
min_date: Optional[str] = None # "dd/mm/yyyy"
max_date: Optional[str] = None # "dd/mm/yyyy"
save_artifacts: bool = False
telegram_token: Optional[str] = None
telegram_chat_id: Optional[str] = None
wait_exact_time: Optional[list] = None # [[minute, second]]
province: Province = Province.BARCELONA
operation_code: OperationType = OperationType.TOMA_HUELLAS
doc_type: DocType
doc_value: str # Passport? "123123123"; Nie? "Y1111111M"
name: str
country: str = "RUSIA"
year_of_birth: Optional[str] = None
card_expire_date: Optional[str] = None # "dd/mm/yyyy"
phone: str
email: str
offices: Optional[list] = field(default_factory=list)
except_offices: Optional[list] = field(default_factory=list)
-
anticaptcha_api_key
— Anti-captcha.com API KEY (not required ifauto_captcha=False
) -
auto_captcha
— Should we use Anti-Captcha plugin? For testing purposes, you can disable it and trick reCaptcha by yourself. Do not select a slot or click buttons, just pretend you're a human reading the page (select text, move cursor etc.) and press Enter in the Terminal. -
auto_office
— Automatic choice of the police station. IfFalse
, again, select an option in the browser manually, do not click "Accept" or "Enter", just press Enter in the Terminal. -
telegram_token
— Telegram bot token for SMS confirmation. Wait for SMS and confirm appointments with a command/code 12345
. If you do not plan to use Telegram, remove this option. -
telegram_chat_id
— Telegram chat id for your bot. Can be used along withtelegram_token
to get notified about appointment in case there is no SMS confirmation (sometimes it happens). Chat id can be obtained by sending any message to your bot and checking results athttps://api.telegram.org/bot<TELEGRAM_TOKEN>/getUpdates
-
min_date
— Minimum date for appointment in "dd/mm/yyyy" format. Appointments available earlier than this date will be skipped. -
max_date
— Maximium date for appointment in "dd/mm/yyyy" format. Appointments available later than this date will be skipped. -
wait_exact_time
— Set specific time (minute and second) you want it to hitSolicitar cita
button -
province
— Province name (Province.BARCELONA
,Province.S_CRUZ_TENERIFE
). -
operation_code
— Procedure (OperationType.AUTORIZACION_DE_REGRESO
,OperationType.BREXIT
,OperationType.CARTA_INVITACION
,OperationType.CERTIFICADOS_NIE
,OperationType.CERTIFICADOS_NIE_NO_COMUN
,OperationType.CERTIFICADOS_RESIDENCIA
,OperationType.CERTIFICADOS_UE
,OperationType.RECOGIDA_DE_TARJETA
,OperationType.SOLICITUD
,OperationType.TOMA_HUELLAS
) -
doc_type
—DocType.NIE
,DocType.PASSPORT
orDocType.DNI
-
doc_value
— Document number, no spaces -
name
— First and Last Name -
year_of_birth
— Year of birth, like "YYYY" -
country
— Country (RUSIA by default). Copypaste yours from the appropriate page. -
card_expire_date
— Card Expiration Date. Probably, it's not important at all, leave it empty. -
phone
— Phone number, no spaces, like "600000000" -
email
— Email -
offices
— Required field forOperationType.RECOGIDA_DE_TARJETA
! If provided, script will try to select the specific police station or end the cycle. ForOperationType.TOMA_HUELLAS
it attempts to select all provided offices one by one, otherwise selects a random one. -
except_offices
— Select offices you would NOT like to get appointment at.
Chrome Profile Persistence
It should be easier to resolve captcha if you use Chrome Profile with some history, so it's better to preserve browser history between attempts.
# chrome_profile_path=f"{os.curdir}/chrome_profiles/", # You can persist Chrome profile between runs, it's good for captcha :)
# chrome_profile_name="Profile 7", # Profile name
Try to uncomment these lines in the run script.
-
For Windows, download wsay and put it in the PATH (see step 4 of Installation)
-
Chrome → Firefox — it's possible as well (tune code, paths, browser run arguments, plugin)
To generate script for Autofill
extension use --autofill
option. This approach allows you to forget about captcha.
$ python grab_me.py --autofill