-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
82 lines (67 loc) · 4.53 KB
/
main.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
import time
import random
# รับข้อมูลจากผู้ใช้ (Prompt user for input)
putBrowser = input("Please enter the number to choose your browser (1 Chrome, 2 Safari, 3 Firefox, 4 Edge): ")
putUsername = input("Type your Roblox Account username here: ")
putPassword = input("Type Roblox Account Password here: ")
# เลือกเบราว์เซอร์ที่ต้องการใช้งาน (Select the browser based on user input)
match putBrowser:
case "1":
print("Ok. Starting Chrome... ")
browser = webdriver.Chrome() # เปิดเบราว์เซอร์ Chrome
case "2":
print("Ok. Starting Safari... ")
browser = webdriver.Safari() # เปิดเบราว์เซอร์ Safari
case "3":
print("Ok. Starting Firefox... ")
browser = webdriver.Firefox() # เปิดเบราว์เซอร์ Firefox
case "4":
print("Ok. Starting Edge... ")
browser = webdriver.Edge() # เปิดเบราว์เซอร์ Edge
case _:
print("Unknown browser!") # หากเลือกเบราว์เซอร์ไม่ถูกต้อง จะหยุดโปรแกรม
exit()
# เข้าสู่ระบบ Roblox (Navigate to the Roblox login page)
print("Logging in... ")
browser.get("https://roblox.com/login")
# รอให้ input field สำหรับ username และ password โหลดขึ้นมา (Wait for the username and password fields to load)
WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, "login-username")))
username = browser.find_element(By.ID, "login-username") # หา input field สำหรับ username
password = browser.find_element(By.ID, "login-password") # หา input field สำหรับ password
# กรอก username และ password (Enter the username and password into the respective fields)
username.send_keys(putUsername)
password.send_keys(putPassword)
# คลิกปุ่มล็อกอิน (Click the login button)
loginBtn = browser.find_element(By.ID, "login-button")
loginBtn.click()
# รอให้เข้าสู่ระบบสำเร็จ (Wait for the login process to complete)
time.sleep(10)
# ลูปสำหรับการติดตามผู้ใช้แบบสุ่ม (Loop for following a random user)
while True:
# สุ่มเลือก ID ผู้ใช้ (Randomly select a user ID)
idRandom = random.randint(100000000, 1000000000) # สามารถปรับช่วง ID ได้ตามต้องการ (Adjust the ID range as needed)
print("Following user with ID:", idRandom)
# เข้าหน้าของผู้ใช้ที่ต้องการติดตาม (Go to the user's page that we want to follow)
browser.get(f"https://roblox.com/users/{idRandom}")
try:
# รอให้ตัวเลือกผู้ใช้โหลดขึ้นมา (Wait for the user options to load)
WebDriverWait(browser, 10).until(
EC.element_to_be_clickable((By.ID, "popover-link"))
)
userOptions = browser.find_element(By.ID, "popover-link")
userOptions.click() # คลิกที่ตัวเลือกของผู้ใช้ (Click on the user options)
time.sleep(2)
# หาปุ่ม Follow โดยใช้ XPath (Find the Follow button using XPath)
followUser = WebDriverWait(browser, 10).until(
EC.element_to_be_clickable((By.XPATH, "//a[@role='menuitem' and @tabindex='-1' and contains(@href, '#')]"))
)
followUser.click() # คลิกปุ่ม Follow (Click the Follow button)
print("FOLLOWED! Moving to next random ID...")
except Exception as e:
print("Could not follow user with ID:", idRandom, "Error:", e) # แสดงข้อความหากไม่สามารถติดตามผู้ใช้ได้ (Print error if unable to follow the user)
# หน่วงเวลา 3 วินาทีก่อนสุ่มติดตามผู้ใช้ถัดไป (Wait for 3 seconds before following the next user)
time.sleep(3)