-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadres-cookie.py
64 lines (46 loc) · 2.07 KB
/
adres-cookie.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import time
import json
import requests
import subprocess
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def create_driver():
options = webdriver.ChromeOptions()
#options.add_argument('--headless')
return webdriver.Chrome(options=options)
while True:
driver = create_driver()
try:
driver.get("https://interaktif.hssgm.gov.tr/Login.aspx")
username_input = driver.find_element(By.NAME, "txtKullaniciAdi")
password_input = driver.find_element(By.NAME, "txtSifre")
username_input.send_keys("") # username
password_input.send_keys("") # password
captcha_image = driver.find_element(By.XPATH, '//*[@src="img/captcha.png"]')
captcha_image.screenshot('hss.jpg')
result = subprocess.run(['python', 'cap.py'], capture_output=True, text=True)
captcha_result = json.loads(result.stdout)
captcha_solution = captcha_result.get('solver')
captcha_input = driver.find_element(By.NAME, "txtDogrulama")
captcha_input.send_keys(captcha_solution)
login_button = driver.find_element(By.ID, "btnGiris")
login_button.click()
time.sleep(2)
try:
error_message = driver.find_element(By.XPATH, "//*[contains(text(), 'Doğrulama Kodu Yanlış')]")
print("Doğrulama Kodu Yanlış, tekrar denenecek...")
driver.quit()
except Exception as e:
print("Giriş başarılı.")
gemi = driver.find_element(By.ID, "rptModulListesi_lnkSideButton_2")
gemi.click()
time.sleep(2)
cookies = driver.get_cookies()
with open('cookies.json', 'w', encoding='utf-8') as cookie_file:
json.dump(cookies, cookie_file, ensure_ascii=False, indent=4)
break
except Exception as e:
print(f"Hata: {e}")
driver.quit()