├── LICENSE ├── README.md ├── booking bot (1).png ├── booking bot (2).png ├── booking bot (3).png ├── booking bot.mp4 ├── browser.bat ├── city.py ├── main.bat ├── main.py ├── message_telegram.py ├── national.py └── nationality.xlsx /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 AI/ML Specialist 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Booking Bot. 2 | ### To run this bot, you should install Python Selenium library. 3 | ```py 4 | pip install selenium 5 | ``` 6 | ### Download Chromedriver from official website. 7 | ### Copy it to C:/ 8 | ### Then run "browser.bat" 9 | ### Finally, run "main.bat" 10 | -------------------------------------------------------------------------------- /booking bot (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hi-tech-AI/Booking-Bot/784fefb7f9b5512b84aca9e22077e996ddd5ebb9/booking bot (1).png -------------------------------------------------------------------------------- /booking bot (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hi-tech-AI/Booking-Bot/784fefb7f9b5512b84aca9e22077e996ddd5ebb9/booking bot (2).png -------------------------------------------------------------------------------- /booking bot (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hi-tech-AI/Booking-Bot/784fefb7f9b5512b84aca9e22077e996ddd5ebb9/booking bot (3).png -------------------------------------------------------------------------------- /booking bot.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hi-tech-AI/Booking-Bot/784fefb7f9b5512b84aca9e22077e996ddd5ebb9/booking bot.mp4 -------------------------------------------------------------------------------- /browser.bat: -------------------------------------------------------------------------------- 1 | chrome.exe -remote-debugging-port=9030 --user-data-dir="C:\chromedriver-win64" -------------------------------------------------------------------------------- /city.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.common.exceptions import * 3 | from selenium.webdriver.common.by import By 4 | from selenium.webdriver.support.ui import Select 5 | from selenium.webdriver.remote.webelement import WebElement 6 | from time import sleep 7 | import message_telegram 8 | 9 | def Find_Element(driver : webdriver.Chrome, by, value : str) -> WebElement: 10 | while True: 11 | try: 12 | element = driver.find_element(by, value) 13 | break 14 | except: 15 | pass 16 | sleep(0.1) 17 | return element 18 | 19 | def Find_Elements(driver : webdriver.Chrome, by, value : str) -> list[WebElement]: 20 | while True: 21 | try: 22 | elements = driver.find_elements(by, value) 23 | if len(elements) > 0: 24 | break 25 | except: 26 | pass 27 | sleep(0.1) 28 | return elements 29 | 30 | def Send_Keys(element : WebElement, content : str): 31 | element.clear() 32 | for i in content: 33 | element.send_keys(i) 34 | sleep(0.2) 35 | 36 | def wait_url(driver : webdriver.Chrome, url : str): 37 | # print(url) 38 | while True: 39 | cur_url = driver.current_url 40 | if cur_url == url: 41 | break 42 | sleep(1) 43 | 44 | def madrid(driver, city_number): 45 | nie = input('Please input N.I.E : ') 46 | fullname = input('Please input Fullname : ') 47 | date = input('Please input date : ') 48 | driver.get('https://icp.administracionelectronica.gob.es/icpplus/index.html') 49 | sleep(0.5) 50 | while True: 51 | region_menu = Find_Element(driver, By.CSS_SELECTOR, 'select[autocomplete="address-level1"]') 52 | region_items = region_menu.find_element(By.TAG_NAME, 'option') 53 | Select(region_menu).select_by_index(33) 54 | sleep(1) 55 | accept_btn1 = Find_Element(driver, By.ID, 'btnAceptar') 56 | driver.execute_script('arguments[0].click();', accept_btn1) 57 | sleep(1) 58 | 59 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplustiem/citar?p=28&locale=es') 60 | sleep(0.5) 61 | police_menu = Find_Element(driver, By.NAME, 'tramiteGrupo[0]') 62 | police_items = police_menu.find_element(By.TAG_NAME, 'option') 63 | Select(police_menu).select_by_index(2) 64 | sleep(1) 65 | accept_btn2 = Find_Element(driver, By.ID, 'btnAceptar') 66 | driver.execute_script('arguments[0].click();', accept_btn2) 67 | sleep(1) 68 | 69 | # wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplustiem/acInfo') 70 | enter_btn = Find_Element(driver, By.ID, 'btnEntrar') 71 | driver.execute_script('arguments[0].click();', enter_btn) 72 | sleep(1) 73 | 74 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplustiem/acEntrada') 75 | sleep(0.5) 76 | input_nie = Find_Element(driver, By.ID, 'txtIdCitado') 77 | Send_Keys(input_nie, nie) 78 | sleep(1) 79 | input_fullname = Find_Element(driver, By.ID, 'txtDesCitado') 80 | Send_Keys(input_fullname, fullname) 81 | sleep(1) 82 | input_date = Find_Element(driver, By.CSS_SELECTOR, 'input[title="Fecha de Caducidad de tu tarjeta actual"]') 83 | Send_Keys(input_date, date) 84 | sleep(1) 85 | next_btn1 = Find_Element(driver, By.ID, 'btnEnviar') 86 | driver.execute_script('arguments[0].click();', next_btn1) 87 | sleep(1) 88 | 89 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplustiem/acValidarEntrada') 90 | sleep(0.5) 91 | next_btn2 = driver.find_element(By.ID, 'btnEnviar') 92 | driver.execute_script('arguments[0].click();', next_btn2) 93 | sleep(1) 94 | 95 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplustiem/acCitar') 96 | sleep(0.5) 97 | try: 98 | sign_btn = driver.find_element(By.ID, 'btnSiguiente') 99 | driver.execute_script('arguments[0].click();', sign_btn) 100 | print('Success!') 101 | message_telegram.send_message(city_number) 102 | break 103 | except: 104 | pass 105 | try: 106 | back_btn = driver.find_element(By.ID, 'btnSalir') 107 | driver.execute_script('arguments[0].click();', back_btn) 108 | driver.delete_all_cookies() 109 | print('Failed!') 110 | sleep(1) 111 | except: 112 | driver.get('https://icp.administracionelectronica.gob.es/icpplus/index.html') 113 | driver.delete_all_cookies() 114 | print('Failed!') 115 | sleep(1) 116 | 117 | def caceres(driver, city_number): 118 | nie = input('Please input N.I.E : ') 119 | fullname = input('Please input Fullname : ') 120 | birth = input('Please input year of birth : ') 121 | nationality_number = input('Please input Nationality Number in Excel file : ') 122 | driver.get('https://icp.administracionelectronica.gob.es/icpplus/index.html') 123 | sleep(0.5) 124 | while True: 125 | region_menu = Find_Element(driver, By.CSS_SELECTOR, 'select[autocomplete="address-level1"]') 126 | region_items = region_menu.find_element(By.TAG_NAME, 'option') 127 | Select(region_menu).select_by_index(12) 128 | sleep(1) 129 | accept_btn1 = Find_Element(driver, By.ID, 'btnAceptar') 130 | driver.execute_script('arguments[0].click();', accept_btn1) 131 | sleep(1) 132 | 133 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/citar?p=10&locale=es') 134 | sleep(0.5) 135 | police_menu = Find_Element(driver, By.NAME, 'tramiteGrupo[1]') 136 | police_items = police_menu.find_element(By.TAG_NAME, 'option') 137 | Select(police_menu).select_by_index(2) 138 | sleep(1) 139 | accept_btn2 = Find_Element(driver, By.ID, 'btnAceptar') 140 | driver.execute_script('arguments[0].click();', accept_btn2) 141 | sleep(1) 142 | 143 | # wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acInfo') 144 | enter_btn = Find_Element(driver, By.ID, 'btnEntrar') 145 | driver.execute_script('arguments[0].click();', enter_btn) 146 | sleep(1) 147 | 148 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acEntrada') 149 | sleep(0.5) 150 | input_nie = Find_Element(driver, By.ID, 'txtIdCitado') 151 | Send_Keys(input_nie, nie) 152 | sleep(1) 153 | input_fullname = Find_Element(driver, By.ID, 'txtDesCitado') 154 | Send_Keys(input_fullname, fullname) 155 | sleep(1) 156 | input_birth = Find_Element(driver, By.ID, 'txtAnnoCitado') 157 | Send_Keys(input_birth, birth) 158 | nationality_menu = Find_Element(driver, By.ID, 'txtPaisNac') 159 | nationality_items = nationality_menu.find_element(By.TAG_NAME, 'option') 160 | Select(nationality_menu).select_by_index(nationality_number) 161 | sleep(1) 162 | next_btn1 = Find_Element(driver, By.ID, 'btnEnviar') 163 | driver.execute_script('arguments[0].click();', next_btn1) 164 | sleep(1) 165 | 166 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acValidarEntrada') 167 | sleep(0.5) 168 | next_btn2 = driver.find_element(By.ID, 'btnEnviar') 169 | driver.execute_script('arguments[0].click();', next_btn2) 170 | sleep(1) 171 | 172 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acCitar') 173 | sleep(0.5) 174 | try: 175 | sign_btn = driver.find_element(By.ID, 'btnSiguiente') 176 | driver.execute_script('arguments[0].click();', sign_btn) 177 | print('Success!') 178 | message_telegram.send_message(city_number) 179 | break 180 | except: 181 | pass 182 | try: 183 | back_btn = driver.find_element(By.ID, 'btnSalir') 184 | driver.execute_script('arguments[0].click();', back_btn) 185 | driver.delete_all_cookies() 186 | print('Failed!') 187 | sleep(1) 188 | except: 189 | driver.get('https://icp.administracionelectronica.gob.es/icpplus/index.html') 190 | driver.delete_all_cookies() 191 | print('Failed!') 192 | sleep(1) 193 | 194 | def albacete(driver, city_number): 195 | nie = input('Please input N.I.E : ') 196 | fullname = input('Please input Fullname : ') 197 | birth = input('Please input year of birth : ') 198 | nationality_number = input('Please input Nationality Number in Excel file : ') 199 | driver.get('https://icp.administracionelectronica.gob.es/icpplus/index.html') 200 | sleep(0.5) 201 | while True: 202 | region_menu = Find_Element(driver, By.CSS_SELECTOR, 'select[autocomplete="address-level1"]') 203 | region_items = region_menu.find_element(By.TAG_NAME, 'option') 204 | Select(region_menu).select_by_index(2) 205 | sleep(1) 206 | accept_btn1 = Find_Element(driver, By.ID, 'btnAceptar') 207 | driver.execute_script('arguments[0].click();', accept_btn1) 208 | sleep(1) 209 | 210 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/citar?p=2&locale=es') 211 | sleep(0.5) 212 | police_menu = Find_Element(driver, By.NAME, 'tramiteGrupo[0]') 213 | police_items = police_menu.find_element(By.TAG_NAME, 'option') 214 | Select(police_menu).select_by_index(13) 215 | sleep(1) 216 | accept_btn2 = Find_Element(driver, By.ID, 'btnAceptar') 217 | driver.execute_script('arguments[0].click();', accept_btn2) 218 | sleep(1) 219 | 220 | # wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acInfo') 221 | enter_btn = Find_Element(driver, By.ID, 'btnEntrar') 222 | driver.execute_script('arguments[0].click();', enter_btn) 223 | sleep(1) 224 | 225 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acEntrada') 226 | sleep(0.5) 227 | input_nie = Find_Element(driver, By.ID, 'txtIdCitado') 228 | Send_Keys(input_nie, nie) 229 | sleep(1) 230 | input_fullname = Find_Element(driver, By.ID, 'txtDesCitado') 231 | Send_Keys(input_fullname, fullname) 232 | sleep(1) 233 | input_birth = Find_Element(driver, By.ID, 'txtAnnoCitado') 234 | Send_Keys(input_birth, birth) 235 | sleep(1) 236 | nationality_menu = Find_Element(driver, By.ID, 'txtPaisNac') 237 | nationality_items = nationality_menu.find_element(By.TAG_NAME, 'option') 238 | Select(nationality_menu).select_by_index(nationality_number) 239 | sleep(1) 240 | next_btn1 = Find_Element(driver, By.ID, 'btnEnviar') 241 | driver.execute_script('arguments[0].click();', next_btn1) 242 | sleep(1) 243 | 244 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acValidarEntrada') 245 | sleep(0.5) 246 | next_btn2 = driver.find_element(By.ID, 'btnEnviar') 247 | driver.execute_script('arguments[0].click();', next_btn2) 248 | sleep(1) 249 | 250 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acCitar') 251 | sleep(0.5) 252 | try: 253 | sign_btn = driver.find_element(By.ID, 'btnSiguiente') 254 | driver.execute_script('arguments[0].click();', sign_btn) 255 | print('Success!') 256 | message_telegram.send_message(city_number) 257 | break 258 | except: 259 | pass 260 | try: 261 | back_btn = driver.find_element(By.ID, 'btnSalir') 262 | driver.execute_script('arguments[0].click();', back_btn) 263 | driver.delete_all_cookies() 264 | print('Failed!') 265 | sleep(1) 266 | except: 267 | driver.get('https://icp.administracionelectronica.gob.es/icpplus/index.html') 268 | driver.delete_all_cookies() 269 | print('Failed!') 270 | sleep(1) 271 | 272 | def valladolid(driver, city_number): 273 | nie = input('Please input N.I.E : ') 274 | fullname = input('Please input Fullname : ') 275 | birth = input('Please input year of birth : ') 276 | nationality_number = input('Please input Nationality Number in Excel file : ') 277 | driver.get('https://icp.administracionelectronica.gob.es/icpplus/index.html') 278 | sleep(0.5) 279 | while True: 280 | region_menu = Find_Element(driver, By.CSS_SELECTOR, 'select[autocomplete="address-level1"]') 281 | region_items = region_menu.find_element(By.TAG_NAME, 'option') 282 | Select(region_menu).select_by_index(50) 283 | sleep(1) 284 | accept_btn1 = Find_Element(driver, By.ID, 'btnAceptar') 285 | driver.execute_script('arguments[0].click();', accept_btn1) 286 | sleep(1) 287 | 288 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/citar?p=47&locale=es') 289 | sleep(0.5) 290 | police_menu = Find_Element(driver, By.NAME, 'tramiteGrupo[1]') 291 | police_items = police_menu.find_element(By.TAG_NAME, 'option') 292 | Select(police_menu).select_by_index(3) 293 | sleep(1) 294 | accept_btn2 = Find_Element(driver, By.ID, 'btnAceptar') 295 | driver.execute_script('arguments[0].click();', accept_btn2) 296 | sleep(1) 297 | 298 | # wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acInfo') 299 | enter_btn = Find_Element(driver, By.ID, 'btnEntrar') 300 | driver.execute_script('arguments[0].click();', enter_btn) 301 | sleep(1) 302 | 303 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acEntrada') 304 | sleep(0.5) 305 | input_nie = Find_Element(driver, By.ID, 'txtIdCitado') 306 | Send_Keys(input_nie, nie) 307 | sleep(1) 308 | input_fullname = Find_Element(driver, By.ID, 'txtDesCitado') 309 | Send_Keys(input_fullname, fullname) 310 | sleep(1) 311 | input_birth = Find_Element(driver, By.ID, 'txtAnnoCitado') 312 | Send_Keys(input_birth, birth) 313 | sleep(1) 314 | nationality_menu = Find_Element(driver, By.ID, 'txtPaisNac') 315 | nationality_items = nationality_menu.find_element(By.TAG_NAME, 'option') 316 | Select(nationality_menu).select_by_index(nationality_number) 317 | sleep(1) 318 | next_btn1 = Find_Element(driver, By.ID, 'btnEnviar') 319 | driver.execute_script('arguments[0].click();', next_btn1) 320 | sleep(1) 321 | 322 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acValidarEntrada') 323 | sleep(0.5) 324 | next_btn2 = driver.find_element(By.ID, 'btnEnviar') 325 | driver.execute_script('arguments[0].click();', next_btn2) 326 | sleep(1) 327 | 328 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acCitar') 329 | sleep(0.5) 330 | try: 331 | sign_btn = driver.find_element(By.ID, 'btnSiguiente') 332 | driver.execute_script('arguments[0].click();', sign_btn) 333 | print('Success!') 334 | message_telegram.send_message(city_number) 335 | break 336 | except: 337 | pass 338 | try: 339 | back_btn = driver.find_element(By.ID, 'btnSalir') 340 | driver.execute_script('arguments[0].click();', back_btn) 341 | driver.delete_all_cookies() 342 | print('Failed!') 343 | sleep(1) 344 | except: 345 | driver.get('https://icp.administracionelectronica.gob.es/icpplus/index.html') 346 | driver.delete_all_cookies() 347 | print('Failed!') 348 | sleep(1) 349 | 350 | def segovia(driver, city_number): 351 | nie = input('Please input N.I.E : ') 352 | fullname = input('Please input Fullname : ') 353 | birth = input('Please input year of birth : ') 354 | nationality_number = input('Please input Nationality Number in Excel file : ') 355 | driver.get('https://icp.administracionelectronica.gob.es/icpplus/index.html') 356 | sleep(0.5) 357 | while True: 358 | region_menu = Find_Element(driver, By.CSS_SELECTOR, 'select[autocomplete="address-level1"]') 359 | region_items = region_menu.find_element(By.TAG_NAME, 'option') 360 | Select(region_menu).select_by_index(43) 361 | sleep(1) 362 | accept_btn1 = Find_Element(driver, By.ID, 'btnAceptar') 363 | driver.execute_script('arguments[0].click();', accept_btn1) 364 | sleep(1) 365 | 366 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/citar?p=40&locale=es') 367 | sleep(0.5) 368 | police_menu = Find_Element(driver, By.NAME, 'tramiteGrupo[1]') 369 | police_items = police_menu.find_element(By.TAG_NAME, 'option') 370 | Select(police_menu).select_by_index(2) 371 | sleep(1) 372 | accept_btn2 = Find_Element(driver, By.ID, 'btnAceptar') 373 | driver.execute_script('arguments[0].click();', accept_btn2) 374 | sleep(1) 375 | 376 | # wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acInfo') 377 | enter_btn = Find_Element(driver, By.ID, 'btnEntrar') 378 | driver.execute_script('arguments[0].click();', enter_btn) 379 | sleep(1) 380 | 381 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acEntrada') 382 | sleep(0.5) 383 | input_nie = Find_Element(driver, By.ID, 'txtIdCitado') 384 | Send_Keys(input_nie, nie) 385 | sleep(1) 386 | input_fullname = Find_Element(driver, By.ID, 'txtDesCitado') 387 | Send_Keys(input_fullname, fullname) 388 | sleep(1) 389 | input_birth = Find_Element(driver, By.ID, 'txtAnnoCitado') 390 | Send_Keys(input_birth, birth) 391 | sleep(1) 392 | nationality_menu = Find_Element(driver, By.ID, 'txtPaisNac') 393 | nationality_items = nationality_menu.find_element(By.TAG_NAME, 'option') 394 | Select(nationality_menu).select_by_index(nationality_number) 395 | sleep(1) 396 | next_btn1 = Find_Element(driver, By.ID, 'btnEnviar') 397 | driver.execute_script('arguments[0].click();', next_btn1) 398 | sleep(1) 399 | 400 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acValidarEntrada') 401 | sleep(0.5) 402 | next_btn2 = driver.find_element(By.ID, 'btnEnviar') 403 | driver.execute_script('arguments[0].click();', next_btn2) 404 | sleep(1) 405 | 406 | wait_url(driver, 'https://icp.administracionelectronica.gob.es/icpplus/acCitar') 407 | sleep(0.5) 408 | try: 409 | sign_btn = driver.find_element(By.ID, 'btnSiguiente') 410 | driver.execute_script('arguments[0].click();', sign_btn) 411 | print('Success!') 412 | message_telegram.send_message(city_number) 413 | break 414 | except: 415 | pass 416 | try: 417 | back_btn = driver.find_element(By.ID, 'btnSalir') 418 | driver.execute_script('arguments[0].click();', back_btn) 419 | driver.delete_all_cookies() 420 | print('Failed!') 421 | sleep(1) 422 | except: 423 | driver.get('https://icp.administracionelectronica.gob.es/icpplus/index.html') 424 | driver.delete_all_cookies() 425 | print('Failed!') 426 | sleep(1) -------------------------------------------------------------------------------- /main.bat: -------------------------------------------------------------------------------- 1 | python main.py -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.webdriver.chrome.options import Options 3 | from selenium.webdriver.chrome.service import Service 4 | import city 5 | 6 | options = Options() 7 | options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.217 Safari/537.3") 8 | options.add_experimental_option("debuggerAddress", "127.0.0.1:9030") 9 | service = Service(executable_path = "C:\chromedriver-win64\chromedriver.exe") 10 | driver = webdriver.Chrome(options = options) 11 | 12 | city_number = input('Please select city number.' + '\n' + '1. Madrid' + '\n' + '2. Cáceres' + '\n' + '3. Albacete' + '\n' + '4. Valladolid' + '\n' + '5. Segovia' + '\n') 13 | 14 | if city_number == '1': 15 | city.madrid(driver, city_number) 16 | if city_number == '2': 17 | city.caceres(driver, city_number) 18 | if city_number == '3': 19 | city.albacete(driver, city_number) 20 | if city_number == '4': 21 | city.valladolid(driver, city_number) 22 | if city_number == '5': 23 | city.segovia(driver, city_number) 24 | -------------------------------------------------------------------------------- /message_telegram.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | def send_message(city_number): 4 | # Set the Telegram API token. 5 | apiToken = "6162486281:AAHoNI5RkKInxqkRqwouMhLzLy6H5mfGS5E" 6 | 7 | # Set the chat ID of the channel you want to send the message to. 8 | chatID1 = "6578526417" 9 | chatID2 = '6656405705' 10 | 11 | # Set the text message you want to send. 12 | if city_number == '1': 13 | message = '- Madrid' + '\n' + '- TIPO DE CITA : ASILO-OFICINA DE ASILO Y REFUGIO."nueva normalidad” Expedición/Renovación Documentos.C/ Pradillo 40' 14 | elif city_number == '2': 15 | message = '- Cáceres' + '\n' + '- TIPO DE CITA : POLICIA - SOLICITO DE ASILO' 16 | elif city_number == '3': 17 | message = '- Albacete' + '\n' + '- TIPO DE CITA : POLICIA - SOLICITO DE ASILO' 18 | elif city_number == '4': 19 | message = '- Valladolid' + '\n' + '- TIPO DE CITA : POLICIA - SOLICITO DE ASILO' 20 | elif city_number == '5': 21 | message = '- Segovia' + '\n' + '- TIPO DE CITA : POLICIA - SOLICITO DE ASILO' 22 | 23 | # Create the request body. 24 | sendData1 = { 25 | "chat_id": chatID1, 26 | "text": message 27 | } 28 | sendData2 = { 29 | "chat_id": chatID2, 30 | "text": message 31 | } 32 | 33 | telegramURL = f'https://api.telegram.org/bot{apiToken}/sendMessage' 34 | 35 | # Send the request to the Telegram API. 36 | response1 = requests.post(telegramURL, sendData1) 37 | response2 = requests.post(telegramURL, sendData2) 38 | 39 | # Check the response status code. 40 | if response1.status_code == 200: 41 | # The message was successfully sent. 42 | print("Message sent successfully!") 43 | else: 44 | # An error occurred. 45 | print("Error sending message: {}".format(response1.status_code)) 46 | 47 | # Check the response status code. 48 | if response2.status_code == 200: 49 | # The message was successfully sent. 50 | print("Message sent successfully!") 51 | else: 52 | # An error occurred. 53 | print("Error sending message: {}".format(response2.status_code)) 54 | 55 | 56 | # if __name__ == '__main__': 57 | # send_message(city_number = '') -------------------------------------------------------------------------------- /national.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.common.exceptions import * 3 | from selenium.webdriver.common.by import By 4 | from selenium.webdriver.chrome.options import Options 5 | from selenium.webdriver.chrome.service import Service 6 | from selenium.webdriver.remote.webelement import WebElement 7 | from selenium.webdriver.chrome.options import Options 8 | from time import sleep 9 | from openpyxl import Workbook 10 | 11 | options = Options() 12 | options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.130 Safari/537.3") 13 | options.add_experimental_option("debuggerAddress", "127.0.0.1:9030") 14 | service = Service(executable_path = "C:\chromedriver-win64\chromedriver.exe") 15 | driver = webdriver.Chrome(options = options) 16 | 17 | def Find_Element(driver : webdriver.Chrome, by, value : str) -> WebElement: 18 | while True: 19 | try: 20 | element = driver.find_element(by, value) 21 | break 22 | except: 23 | pass 24 | sleep(0.1) 25 | return element 26 | 27 | def Find_Elements(driver : webdriver.Chrome, by, value : str) -> list[WebElement]: 28 | while True: 29 | try: 30 | elements = driver.find_elements(by, value) 31 | if len(elements) > 0: 32 | break 33 | except: 34 | pass 35 | sleep(0.1) 36 | return elements 37 | 38 | def Send_Keys(element : WebElement, content : str): 39 | element.clear() 40 | for i in content: 41 | element.send_keys(i) 42 | sleep(0.1) 43 | 44 | # driver.get('https://icp.administracionelectronica.gob.es/icpplus/index.html') 45 | 46 | wb = Workbook() 47 | sheet = wb.active 48 | item = ['No', 'Nationality'] 49 | 50 | for i in range(0, 2): 51 | sheet.cell(row = 1, column = i + 1).value = item[i] 52 | 53 | nationalitys = Find_Elements(driver, By.TAG_NAME, 'option') 54 | 55 | print(len(nationalitys)) 56 | 57 | start_row = 2 58 | for nationality in nationalitys: 59 | sheet.cell(row = start_row, column = 1).value = start_row - 1 60 | sheet.cell(row = start_row, column = 2).value = nationality.text 61 | start_row += 1 62 | 63 | wb.save('nationality.xlsx') -------------------------------------------------------------------------------- /nationality.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hi-tech-AI/Booking-Bot/784fefb7f9b5512b84aca9e22077e996ddd5ebb9/nationality.xlsx --------------------------------------------------------------------------------