-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
75 lines (62 loc) · 2.1 KB
/
Copy pathsetup.py
File metadata and controls
75 lines (62 loc) · 2.1 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
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
from playwright.sync_api import sync_playwright
from playwright_stealth import stealth_sync
import os
import sys
import shutil
user = "Aaron"
if len(sys.argv) > 1:
user = sys.argv[1]
# Base user folder
user_base_dir = os.path.abspath(f".\\Users\\{user}")
# Create profile directory
user_data_dir = os.path.join(user_base_dir, "chrome_profile")
os.makedirs(user_data_dir, exist_ok=True)
# Create other necessary folders
mycv_dir = os.path.join(user_base_dir, "mycv")
mycl_dir = os.path.join(user_base_dir, "mycl")
os.makedirs(mycv_dir, exist_ok=True)
os.makedirs(mycl_dir, exist_ok=True)
# Reference base directory (template source)
template_user_dir = os.path.abspath(".\\Users\\John_Doe")
# List of required files to copy
required_files = [
"info.yaml",
"job_ids.txt",
"resume.txt"
]
for filename in required_files:
dest_path = os.path.join(user_base_dir, filename)
src_path = os.path.join(template_user_dir, filename)
if not os.path.exists(dest_path):
shutil.copyfile(src_path, dest_path)
print(f"Setup complete for user: {user}. Proceed to login to Seek.")
with sync_playwright() as p:
# Launch Chromiums
browser = p.chromium.launch_persistent_context(
user_data_dir=user_data_dir,
headless=False,
no_viewport=True,
args=[
'--disable-blink-features=AutomationControlled',
'--no-sandbox',
'--disable-web-security',
'--disable-infobars',
"--start-maximized",
],
)
# Open the first page (Seek login)
page = browser.new_page()
browser.pages[0].close()
page.goto("https://login.seek.com/")
input("Press Enter after logging in...")
print("Logged in successfully!")
input("Press Enter to close the browser...")
# Close the browser after actions
browser.close()
# try:
# if os.path.exists(backup_dir):
# shutil.rmtree(backup_dir) # Remove old backup
# shutil.copytree(user_data_dir, backup_dir)
# print(f"Copied user data from '{user_data_dir}' to '{backup_dir}'.")
# except Exception as e:
# print(f"Error copying profile: {e}")