vortexa64 commited on
Commit
3394532
·
verified ·
1 Parent(s): bb20ecd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -12
app.py CHANGED
@@ -1,10 +1,19 @@
1
  from flask import Flask, request, jsonify, send_file
2
- from selenium import webdriver
3
- from selenium.webdriver.chrome.options import Options
4
  import time
 
 
5
 
6
  app = Flask(__name__)
7
 
 
 
 
 
 
 
 
 
 
8
  @app.route('/')
9
  def index():
10
  return send_file('index.html')
@@ -15,18 +24,41 @@ def inject():
15
  link = data.get('link')
16
  jumlah = int(data.get('jumlah'))
17
 
18
- options = Options()
19
- options.add_argument('--headless')
20
- options.add_argument('--no-sandbox')
21
- options.add_argument('--disable-dev-shm-usage')
22
- driver = webdriver.Chrome(options=options)
 
 
 
23
 
24
- try:
25
- for _ in range(jumlah):
 
 
 
 
 
 
 
26
  driver.get(link)
27
- time.sleep(2)
28
- finally:
29
- driver.quit()
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  return jsonify({"status": "success", "sent": jumlah})
32
 
 
1
  from flask import Flask, request, jsonify, send_file
 
 
2
  import time
3
+ import random
4
+ import undetected_chromedriver as uc
5
 
6
  app = Flask(__name__)
7
 
8
+ # Fungsi ambil proxy acak dari proxy.txt
9
+ def get_random_proxy():
10
+ try:
11
+ with open('proxy.txt', 'r') as f:
12
+ proxies = [line.strip() for line in f if line.strip()]
13
+ return random.choice(proxies)
14
+ except:
15
+ return None
16
+
17
  @app.route('/')
18
  def index():
19
  return send_file('index.html')
 
24
  link = data.get('link')
25
  jumlah = int(data.get('jumlah'))
26
 
27
+ for _ in range(jumlah):
28
+ options = uc.ChromeOptions()
29
+ options.add_argument('--no-sandbox')
30
+ options.add_argument('--disable-dev-shm-usage')
31
+ options.add_argument('--disable-blink-features=AutomationControlled')
32
+ options.add_argument(
33
+ 'user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114 Safari/537.36'
34
+ )
35
 
36
+ # Tambah proxy kalau tersedia
37
+ proxy = get_random_proxy()
38
+ if proxy:
39
+ options.add_argument(f'--proxy-server=http://{proxy}')
40
+ print(f'[+] Pakai proxy: {proxy}')
41
+
42
+ driver = uc.Chrome(options=options, headless=True)
43
+
44
+ try:
45
  driver.get(link)
46
+ time.sleep(4)
47
+
48
+ # Paksa play video
49
+ try:
50
+ driver.execute_script("""
51
+ const video = document.querySelector('video');
52
+ if(video){ video.play(); }
53
+ """)
54
+ time.sleep(10) # Tahan biar view masuk
55
+ except Exception as e:
56
+ print("[!] Gagal play:", e)
57
+
58
+ except Exception as e:
59
+ print("[!] Gagal buka link:", e)
60
+ finally:
61
+ driver.quit()
62
 
63
  return jsonify({"status": "success", "sent": jumlah})
64