Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,11 @@
|
|
1 |
-
import streamlit as st
|
2 |
from selenium import webdriver
|
3 |
from selenium.webdriver.common.by import By
|
4 |
from selenium.webdriver.support.ui import WebDriverWait
|
5 |
from selenium.webdriver.support import expected_conditions as EC
|
6 |
from webdriver_manager.chrome import ChromeDriverManager
|
7 |
import time
|
8 |
-
import threading
|
9 |
|
10 |
-
# تنظیمات
|
11 |
USERNAME = "09393632537"
|
12 |
PASSWORD = "Ali0916/"
|
13 |
LOGIN_URL = "https://karsood.ir"
|
@@ -15,77 +13,56 @@ WAIT_TIME = 10
|
|
15 |
|
16 |
def initialize_driver():
|
17 |
options = webdriver.ChromeOptions()
|
18 |
-
options.add_argument("--
|
19 |
-
options.add_argument("--disable-gpu")
|
20 |
-
options.add_argument("--no-sandbox")
|
21 |
return webdriver.Chrome(ChromeDriverManager().install(), options=options)
|
22 |
|
23 |
def login(driver):
|
24 |
driver.get(LOGIN_URL)
|
25 |
|
26 |
-
|
|
|
27 |
EC.presence_of_element_located((By.NAME, "username"))
|
28 |
-
)
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
|
34 |
def auto_clicker(driver):
|
35 |
-
while
|
36 |
try:
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
for element in clickables:
|
39 |
try:
|
40 |
element.click()
|
41 |
-
|
42 |
time.sleep(1)
|
43 |
except:
|
44 |
continue
|
|
|
|
|
45 |
time.sleep(10)
|
|
|
46 |
except Exception as e:
|
47 |
-
|
|
|
48 |
|
49 |
-
def
|
50 |
driver = initialize_driver()
|
51 |
try:
|
52 |
login(driver)
|
53 |
-
time.sleep(
|
54 |
auto_clicker(driver)
|
55 |
finally:
|
56 |
driver.quit()
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
threading.Thread(target=main_automation).start()
|
61 |
-
|
62 |
-
# رابط کاربری ساده شده
|
63 |
-
st.set_page_config(page_title="Karsood AutoBot", layout="wide")
|
64 |
-
st.markdown("""
|
65 |
-
<style>
|
66 |
-
.stButton>button {
|
67 |
-
background-color: #4CAF50;
|
68 |
-
color: white;
|
69 |
-
padding: 12px 24px;
|
70 |
-
border-radius: 5px;
|
71 |
-
}
|
72 |
-
</style>
|
73 |
-
""", unsafe_allow_html=True)
|
74 |
-
|
75 |
-
if 'running' not in st.session_state:
|
76 |
-
st.session_state.running = False
|
77 |
-
|
78 |
-
if not st.session_state.running:
|
79 |
-
start_automation()
|
80 |
-
st.experimental_rerun()
|
81 |
-
|
82 |
-
st.title("Karsood AutoBot 🤖")
|
83 |
-
st.write("""
|
84 |
-
### Dar hal ejra-ye automatik:
|
85 |
-
- **Username:** `09393632537`
|
86 |
-
- **Password:** `••••••••`
|
87 |
-
""")
|
88 |
-
|
89 |
-
stop_btn = st.button("⛔ Stop")
|
90 |
-
if stop_btn:
|
91 |
-
st.session_state.running = False
|
|
|
|
|
1 |
from selenium import webdriver
|
2 |
from selenium.webdriver.common.by import By
|
3 |
from selenium.webdriver.support.ui import WebDriverWait
|
4 |
from selenium.webdriver.support import expected_conditions as EC
|
5 |
from webdriver_manager.chrome import ChromeDriverManager
|
6 |
import time
|
|
|
7 |
|
8 |
+
# تنظیمات اولیه
|
9 |
USERNAME = "09393632537"
|
10 |
PASSWORD = "Ali0916/"
|
11 |
LOGIN_URL = "https://karsood.ir"
|
|
|
13 |
|
14 |
def initialize_driver():
|
15 |
options = webdriver.ChromeOptions()
|
16 |
+
options.add_argument("--disable-notifications")
|
|
|
|
|
17 |
return webdriver.Chrome(ChromeDriverManager().install(), options=options)
|
18 |
|
19 |
def login(driver):
|
20 |
driver.get(LOGIN_URL)
|
21 |
|
22 |
+
# ورود اطلاعات کاربری
|
23 |
+
username_field = WebDriverWait(driver, WAIT_TIME).until(
|
24 |
EC.presence_of_element_located((By.NAME, "username"))
|
25 |
+
)
|
26 |
+
password_field = WebDriverWait(driver, WAIT_TIME).until(
|
27 |
+
EC.presence_of_element_located((By.NAME, "password"))
|
28 |
+
)
|
29 |
|
30 |
+
username_field.send_keys(USERNAME)
|
31 |
+
password_field.send_keys(PASSWORD)
|
32 |
+
password_field.submit()
|
33 |
+
print("(*) Vared shodam!")
|
34 |
|
35 |
def auto_clicker(driver):
|
36 |
+
while True:
|
37 |
try:
|
38 |
+
# جستجو برای المانهای قابل کلیک
|
39 |
+
clickables = WebDriverWait(driver, WAIT_TIME).until(
|
40 |
+
EC.presence_of_all_elements_located((By.XPATH, "//a | //button"))
|
41 |
+
)
|
42 |
+
|
43 |
for element in clickables:
|
44 |
try:
|
45 |
element.click()
|
46 |
+
print(f"(+) Click kardam: {element.text[:20]}... | Tag: {element.tag_name}")
|
47 |
time.sleep(1)
|
48 |
except:
|
49 |
continue
|
50 |
+
|
51 |
+
print("(*) Check dobare dar 10s...")
|
52 |
time.sleep(10)
|
53 |
+
|
54 |
except Exception as e:
|
55 |
+
print(f"(!) Error: {str(e)[:50]}...")
|
56 |
+
time.sleep(5)
|
57 |
|
58 |
+
def main():
|
59 |
driver = initialize_driver()
|
60 |
try:
|
61 |
login(driver)
|
62 |
+
time.sleep(5)
|
63 |
auto_clicker(driver)
|
64 |
finally:
|
65 |
driver.quit()
|
66 |
|
67 |
+
if __name__ == "__main__":
|
68 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|