Update main.py
Browse files
main.py
CHANGED
@@ -57,10 +57,17 @@ logger.info(f"OPENAI_API_KEY value: {OPENAI_API_KEY}")
|
|
57 |
|
58 |
def get_cookie():
|
59 |
try:
|
|
|
60 |
options = ChromiumOptions()
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
options.set_argument('--headless=new')
|
63 |
-
# 添加容器环境所需的启动参数
|
64 |
options.set_argument('--no-sandbox')
|
65 |
options.set_argument('--disable-dev-shm-usage')
|
66 |
options.set_argument('--disable-gpu')
|
@@ -70,16 +77,22 @@ def get_cookie():
|
|
70 |
options.set_argument('--no-first-run')
|
71 |
options.set_argument('--no-zygote')
|
72 |
options.set_argument('--single-process')
|
73 |
-
options.set_argument('--disable-dev-shm-usage')
|
74 |
options.set_argument('--remote-debugging-port=9222')
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
page = ChromiumPage(addr_or_opts=options)
|
77 |
-
page.set.window.size(1920, 1080)
|
78 |
-
page.set.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"
|
79 |
|
|
|
80 |
page.get("https://chat.akash.network/")
|
81 |
time.sleep(10)
|
82 |
|
|
|
83 |
cookies = page.cookies()
|
84 |
if not cookies:
|
85 |
page.quit()
|
|
|
57 |
|
58 |
def get_cookie():
|
59 |
try:
|
60 |
+
# 创建配置对象
|
61 |
options = ChromiumOptions()
|
62 |
+
|
63 |
+
# 设置浏览器路径(如果需要)
|
64 |
+
# options.set_browser_path('/usr/bin/google-chrome')
|
65 |
+
|
66 |
+
# 设置用户数据目录
|
67 |
+
options.set_argument('--user-data-dir=/tmp/chrome-data')
|
68 |
+
|
69 |
+
# 设置无头模式和其他参数
|
70 |
options.set_argument('--headless=new')
|
|
|
71 |
options.set_argument('--no-sandbox')
|
72 |
options.set_argument('--disable-dev-shm-usage')
|
73 |
options.set_argument('--disable-gpu')
|
|
|
77 |
options.set_argument('--no-first-run')
|
78 |
options.set_argument('--no-zygote')
|
79 |
options.set_argument('--single-process')
|
|
|
80 |
options.set_argument('--remote-debugging-port=9222')
|
81 |
|
82 |
+
# 设置窗口大小
|
83 |
+
options.set_argument('--window-size=1920,1080')
|
84 |
+
|
85 |
+
# 设置用户代理
|
86 |
+
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')
|
87 |
+
|
88 |
+
# 创建页面对象
|
89 |
page = ChromiumPage(addr_or_opts=options)
|
|
|
|
|
90 |
|
91 |
+
# 访问目标网站
|
92 |
page.get("https://chat.akash.network/")
|
93 |
time.sleep(10)
|
94 |
|
95 |
+
# 获取 cookies
|
96 |
cookies = page.cookies()
|
97 |
if not cookies:
|
98 |
page.quit()
|