import os # Paksa patcher undetected-chromedriver ke /tmp os.environ["UCDP_DATA_PATH"] = "/tmp/ucdata" os.environ["XDG_CACHE_HOME"] = "/tmp/.cache" os.environ["XDG_CONFIG_HOME"] = "/tmp/.config" os.environ["XDG_DATA_HOME"] = "/tmp/.local/share" os.environ["HOME"] = "/tmp" import time import undetected_chromedriver as uc from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC def bypass_shinigami(url: str) -> dict: options = uc.ChromeOptions() options.add_argument("--headless=new") options.add_argument("--disable-gpu") options.add_argument("--no-sandbox") options.add_argument("--disable-dev-shm-usage") options.add_argument("--disable-software-rasterizer") options.add_argument("--disable-dev-tools") options.add_argument("--disable-setuid-sandbox") options.add_argument("--remote-debugging-port=9222") options.add_argument("--user-data-dir=/tmp/chrome-user-data") options.add_argument("--disk-cache-dir=/tmp/.cache/chrome") options.add_argument( "--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" ) driver = uc.Chrome(options=options, headless=True, user_data_dir="/tmp/chrome-user-data", data_path="/tmp/ucdata") try: driver.get(url) # Tunggu maksimal 5 detik sampai judul halaman bukan "Just a moment..." WebDriverWait(driver, 5).until( lambda d: "Just a moment" not in d.title ) time.sleep(2) # Tambahan delay agar benar-benar lolos link_elem = driver.find_elements(By.TAG_NAME, "a") link = link_elem[0].get_attribute("href") if link_elem else None title = driver.title meta_elements = driver.find_elements(By.XPATH, "//head/meta") headers = {} for meta in meta_elements: name = meta.get_attribute("name") or meta.get_attribute("property") content = meta.get_attribute("content") if name and content: headers[name] = content return { "status": "success", "message": "OK", "bypassed_url": link, "title": title, "headers": headers } except Exception as e: return { "status": "error", "message": f"Error: {e}", "bypassed_url": None, "title": None, "headers": {} } finally: driver.quit()