Skip to content

Commit f5ed866

Browse files
authored
Python版更新
Python版推送更新,JS版本已弃用不维护(仍可使用)
2 parents eff07b7 + 920fb47 commit f5ed866

13 files changed

Lines changed: 4535 additions & 246 deletions

.gitignore

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,94 @@ public
133133
.vscode/
134134

135135
# Custom
136-
errors/
136+
errors/
137+
138+
# Python
139+
__pycache__/
140+
*.py[cod]
141+
*$py.class
142+
143+
# Python Libraries
144+
*.egg-info/
145+
*.egg
146+
147+
# Distribution / packaging
148+
.Python
149+
build/
150+
dist/
151+
part/
152+
sdist/
153+
*.manifest
154+
*.spec
155+
wheels/
156+
157+
# PyInstaller
158+
# Usually these files are written by a python script from a template
159+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
160+
*.manifest
161+
*.spec
162+
163+
# Installer logs
164+
pip-log.txt
165+
pip-delete-this-directory.txt
166+
167+
# Unit test / coverage reports
168+
htmlcov/
169+
.tox/
170+
.nox/
171+
.coverage
172+
.coverage.*
173+
.cache
174+
nosetests.xml
175+
coverage.xml
176+
*.cover
177+
*.py,cover
178+
.hypothesis/
179+
.pytest_cache/
180+
181+
# Environments
182+
.env
183+
.venv
184+
env/
185+
venv/
186+
ENV/
187+
env.bak/
188+
venv.bak/
189+
190+
# Jupyter Notebook
191+
.ipynb_checkpoints
192+
profile_default/
193+
ipython_config.py
194+
195+
# pyenv
196+
.python-version
197+
198+
# Celery stuff
199+
celerybeat-schedule
200+
celerybeat.pid
201+
202+
# SageMath parsed files
203+
*.sage.py
204+
205+
# Environments
206+
.env
207+
.venv
208+
env/
209+
venv/
210+
ENV/
211+
env.bak/
212+
venv.bak/
213+
214+
# Error snapshots directory (Python specific)
215+
errors_py/
216+
217+
# Authentication Profiles (Sensitive)
218+
auth_profiles/active/
219+
auth_profiles/saved/
220+
221+
# Camoufox/Playwright Profile Data (Assume these are generated/temporary)
222+
camoufox_profile/
223+
chrome_temp_profile/
224+
225+
# Deprecated Javascript Version node_modules
226+
deprecated_javascript_version/node_modules/

README.md

Lines changed: 411 additions & 142 deletions
Large diffs are not rendered by default.

deprecated_javascript_version/README.md

Lines changed: 231 additions & 0 deletions
Large diffs are not rendered by default.

auto_connect_aistudio.cjs renamed to deprecated_javascript_version/auto_connect_aistudio.cjs

File renamed without changes.

package.json renamed to deprecated_javascript_version/package.json

File renamed without changes.

test.js renamed to deprecated_javascript_version/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import readline from 'readline'; // 引入 readline 模块
77
// --- 配置 ---
88
// 1. baseURL: 指向你本地运行的 server.js 代理服务器
99
// server.js 监听 3000 端口,并提供 /v1 路径
10-
const LOCAL_PROXY_URL = 'http://localhost:2048/v1'; // 确保端口号与 server.js 一致
10+
const LOCAL_PROXY_URL = 'http://127.0.0.1:2048/v1/'; // 确保端口号与 server.js 一致
1111

1212
// 2. apiKey: 对于本地代理,这个 key 不会被验证,可以填写任意字符串
1313
const DUMMY_API_KEY = 'no-key-needed-for-local-proxy';

fetch_camoufox_data.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import ssl
2+
import sys
3+
import traceback
4+
5+
# --- WARNING: THIS SCRIPT DISABLES SSL VERIFICATION --- #
6+
# --- USE ONLY IF YOU TRUST YOUR NETWORK --- #
7+
# --- AND `camoufox fetch` FAILS DUE TO SSL --- #
8+
9+
print("="*60)
10+
print("WARNING: This script will temporarily disable SSL certificate verification")
11+
print(" globally for this Python process to attempt fetching Camoufox data.")
12+
print(" This can expose you to security risks like man-in-the-middle attacks.")
13+
print("="*60)
14+
15+
confirm = input("Do you understand the risks and want to proceed? (yes/NO): ").strip().lower()
16+
17+
if confirm != 'yes':
18+
print("Operation cancelled by user.")
19+
sys.exit(0)
20+
21+
print("\nAttempting to disable SSL verification...")
22+
original_ssl_context = None
23+
try:
24+
# Store the original context creation function
25+
if hasattr(ssl, '_create_default_https_context'):
26+
original_ssl_context = ssl._create_default_https_context
27+
28+
# Get the unverified context creation function
29+
_create_unverified_https_context = ssl._create_unverified_context
30+
31+
# Monkey patch the default context creation
32+
ssl._create_default_https_context = _create_unverified_https_context
33+
print("SSL verification temporarily disabled for this process.")
34+
except AttributeError:
35+
print("ERROR: Cannot disable SSL verification on this Python version (missing necessary SSL functions).")
36+
sys.exit(1)
37+
except Exception as e:
38+
print(f"ERROR: An unexpected error occurred while trying to disable SSL verification: {e}")
39+
traceback.print_exc()
40+
sys.exit(1)
41+
42+
# Now, try to import and run the fetch command logic from camoufox
43+
print("\nAttempting to run Camoufox fetch logic...")
44+
fetch_success = False
45+
try:
46+
# The exact way to trigger fetch programmatically might differ.
47+
# This tries to import the CLI module and run the fetch command.
48+
from camoufox import cli
49+
# Simulate command line arguments: ['fetch']
50+
# Note: cli.cli() might exit the process directly on completion or error.
51+
# We assume it might raise an exception or return normally.
52+
cli.cli(['fetch'])
53+
print("Camoufox fetch process seems to have completed.")
54+
# We assume success if no exception was raised and the process didn't exit.
55+
# A more robust check would involve verifying the downloaded files,
56+
# but that's beyond the scope of this simple script.
57+
fetch_success = True
58+
except ImportError:
59+
print("\nERROR: Could not import camoufox.cli. Make sure camoufox package is installed.")
60+
print(" Try running: pip show camoufox")
61+
except FileNotFoundError as e:
62+
print(f"\nERROR during fetch (FileNotFoundError): {e}")
63+
print(" This might indicate issues with file paths or permissions during download/extraction.")
64+
print(" Please check network connectivity and directory write permissions.")
65+
except SystemExit as e:
66+
# The CLI might use sys.exit(). We interpret non-zero exit codes as failure.
67+
if e.code == 0:
68+
print("Camoufox fetch process exited successfully (code 0).")
69+
fetch_success = True
70+
else:
71+
print(f"\nERROR: Camoufox fetch process exited with error code: {e.code}")
72+
except Exception as e:
73+
print(f"\nERROR: An unexpected error occurred while running camoufox fetch: {e}")
74+
traceback.print_exc()
75+
finally:
76+
# Attempt to restore the original SSL context
77+
if original_ssl_context:
78+
try:
79+
ssl._create_default_https_context = original_ssl_context
80+
print("\nOriginal SSL context restored.")
81+
except Exception as restore_e:
82+
print(f"\nWarning: Failed to restore original SSL context: {restore_e}")
83+
else:
84+
# If we couldn't store the original, we can't restore it.
85+
# The effect was process-local anyway.
86+
pass
87+
88+
if fetch_success:
89+
print("\nFetch attempt finished. Please verify if Camoufox browser files were downloaded successfully.")
90+
else:
91+
print("\nFetch attempt failed or exited with an error.")
92+
93+
print("Script finished.")

0 commit comments

Comments
 (0)