vbnotebook
This commit is contained in:
36
20 Loginwithsavedcookies.py
Normal file
36
20 Loginwithsavedcookies.py
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
COOKIE_FILE = Path("sktorrent_cookies.json")
|
||||
LOGIN_URL = "https://sktorrent.eu/torrent/torrents_v2.php?active=0"
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=False)
|
||||
context = browser.new_context()
|
||||
|
||||
# Load saved cookies
|
||||
if COOKIE_FILE.exists():
|
||||
with open(COOKIE_FILE, "r") as f:
|
||||
cookies = json.load(f)
|
||||
context.add_cookies(cookies)
|
||||
print("🔄 Loaded cookies.")
|
||||
else:
|
||||
print("❌ Cookie file not found. Run the manual login script first.")
|
||||
exit()
|
||||
|
||||
page = context.new_page()
|
||||
page.goto(LOGIN_URL)
|
||||
|
||||
page.wait_for_load_state("networkidle")
|
||||
|
||||
# Check if login form is visible
|
||||
if page.locator('input[name="uid"]').count() == 0:
|
||||
print("✅ Already logged in using cookies!")
|
||||
else:
|
||||
print("❌ Cookies invalid or expired. Please re-login manually to refresh cookies.")
|
||||
|
||||
page.wait_for_timeout(3000)
|
||||
Reference in New Issue
Block a user