forked from forcedotcom/pub-sub-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathte
More file actions
45 lines (39 loc) · 1.52 KB
/
Copy pathte
File metadata and controls
45 lines (39 loc) · 1.52 KB
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
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
import time
import sys
import tempfile
KICK_URL = "https://kick.com/elshowdelast"
def view_bot(bot_id):
print(f"🟢 Bot {bot_id} iniciando...", flush=True)
options = Options()
options.add_argument("--headless=new")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-gpu")
options.add_argument("--window-size=1920,1080")
options.add_argument("--disable-extensions")
options.add_argument("--disable-software-rasterizer")
# Añade un user-data-dir único por bot para evitar conflicto
temp_dir = tempfile.mkdtemp(prefix=f"bot_{bot_id}_profile_")
options.add_argument(f"--user-data-dir={temp_dir}")
service = Service("/usr/local/bin/chromedriver")
driver = None
try:
driver = webdriver.Chrome(service=service, options=options)
driver.get(KICK_URL)
print(f"✅ Bot {bot_id} viendo {KICK_URL}", flush=True)
time.sleep(120) # 2 minutos
print(f"🔵 Bot {bot_id} finalizó la visualización correctamente de {KICK_URL}", flush=True)
except Exception as e:
print(f"❌ Bot {bot_id} error: {e}", flush=True)
finally:
if driver:
try:
driver.quit()
except:
pass
if __name__ == "__main__":
bot_id = sys.argv[1] if len(sys.argv) > 1 else "1"
view_bot(bot_id)