python Copy
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
# Chrome WebDriver をセットアップ
driver = webdriver.Chrome()
# IRCTC を開く
driver.get("https://www.irctc.co.in")
time.sleep(2)
# ログイン
driver.find_element(By.ID, "userId").send_keys("YOUR_USERNAME")
driver.find_element(By.ID, "pwd").send_keys("YOUR_PASSWORD")
driver.find_element(By.XPATH, "//button[contains(text(),'SIGN IN')]").click()
time.sleep(3)
# 旅程の詳細を入力
driver.find_element(By.ID, "origin").send_keys("DELHI (NDLS)")
driver.find_element(By.ID, "destination").send_keys("MUMBAI (CSTM)")
driver.find_element(By.ID, "journeyDate").send_keys("20-07-2024")
driver.find_element(By.ID, "searchBtn").click()
time.sleep(5)
# 列車とクラスを選択
driver.find_element(By.XPATH, "//span[contains(text(),'Book Now')]").click()
time.sleep(2)
# 乗客情報を入力(手動またはスクリプト経由)
print("CAPTCHAを手動で解決!")
time.sleep(30) # CAPTCHAを待機
# 支払いへ進む
driver.find_element(By.ID, "paymentSubmitBtn").click()