Update main.py
Browse files
main.py
CHANGED
@@ -59,43 +59,10 @@ def get_cookie():
|
|
59 |
try:
|
60 |
logger.info("Starting cookie retrieval process...")
|
61 |
|
62 |
-
#
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
chrome_path = os.getenv('CHROME_PATH', '/usr/bin/google-chrome-stable')
|
67 |
-
logger.info(f"Using Chrome path: {chrome_path}")
|
68 |
-
options.set_browser_path(chrome_path)
|
69 |
-
|
70 |
-
# 设置用户数据目录
|
71 |
-
user_data_dir = '/tmp/chrome-data'
|
72 |
-
logger.info(f"Using user data directory: {user_data_dir}")
|
73 |
-
options.set_argument(f'--user-data-dir={user_data_dir}')
|
74 |
-
|
75 |
-
# 设置无头模式和其他参数
|
76 |
-
options.set_argument('--headless=new')
|
77 |
-
options.set_argument('--no-sandbox')
|
78 |
-
options.set_argument('--disable-dev-shm-usage')
|
79 |
-
options.set_argument('--disable-gpu')
|
80 |
-
options.set_argument('--disable-software-rasterizer')
|
81 |
-
options.set_argument('--disable-extensions')
|
82 |
-
options.set_argument('--disable-setuid-sandbox')
|
83 |
-
options.set_argument('--no-first-run')
|
84 |
-
options.set_argument('--no-zygote')
|
85 |
-
options.set_argument('--single-process')
|
86 |
-
options.set_argument('--remote-debugging-port=9222')
|
87 |
-
options.set_argument('--window-size=1920,1080')
|
88 |
-
options.set_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36')
|
89 |
-
|
90 |
-
# 启用详细日志
|
91 |
-
options.set_argument('--enable-logging')
|
92 |
-
options.set_argument('--v=1')
|
93 |
-
|
94 |
-
# 设置调试地址
|
95 |
-
options.set_argument('--remote-debugging-address=127.0.0.1')
|
96 |
-
|
97 |
-
logger.info("Creating ChromiumPage instance...")
|
98 |
-
page = ChromiumPage(addr_or_opts=options)
|
99 |
|
100 |
logger.info("Navigating to target website...")
|
101 |
page.get("https://chat.akash.network/")
|
|
|
59 |
try:
|
60 |
logger.info("Starting cookie retrieval process...")
|
61 |
|
62 |
+
# 使用全局配置创建页面
|
63 |
+
# DrissionPage 会自动使用 /usr/local/lib/python3.10/site-packages/DrissionPage/_configs/configs.ini 中的配置
|
64 |
+
logger.info("Creating ChromiumPage instance with global config...")
|
65 |
+
page = ChromiumPage()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
logger.info("Navigating to target website...")
|
68 |
page.get("https://chat.akash.network/")
|