first init
This commit is contained in:
parent
4b885d4c54
commit
b6b517a876
13
browser.js
13
browser.js
@ -12,10 +12,21 @@ export async function getBrowserAndContexts({ headless, slowMo }) {
|
|||||||
if (adspowerUserId) {
|
if (adspowerUserId) {
|
||||||
console.log('[FP] 使用 AdsPower 指纹浏览器');
|
console.log('[FP] 使用 AdsPower 指纹浏览器');
|
||||||
const apiBase = process.env.ADSPOWER_API || 'http://local.adspower.net:50325';
|
const apiBase = process.env.ADSPOWER_API || 'http://local.adspower.net:50325';
|
||||||
const startUrl = `${apiBase}/api/v1/browser/start?user_id=${encodeURIComponent(adspowerUserId)}`;
|
const apiKey = process.env.ADSPOWER_API_KEY;
|
||||||
|
let startUrl = `${apiBase}/api/v1/browser/start?user_id=${encodeURIComponent(adspowerUserId)}`;
|
||||||
|
if (apiKey && apiKey.trim()) {
|
||||||
|
startUrl += `&api_key=${encodeURIComponent(apiKey)}`;
|
||||||
|
console.log('[FP] 使用 API Key 认证');
|
||||||
|
}
|
||||||
const resp = await fetch(startUrl);
|
const resp = await fetch(startUrl);
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
if (data.code !== 0) {
|
if (data.code !== 0) {
|
||||||
|
console.error('[AdsPower] API 返回错误:', JSON.stringify(data, null, 2));
|
||||||
|
console.error('\n解决方案:');
|
||||||
|
console.error('1. 确保 AdsPower 应用已启动并登录');
|
||||||
|
console.error('2. 检查配置文件 ID 是否正确: ' + adspowerUserId);
|
||||||
|
console.error('3. 如果需要 API Key,请在 AdsPower 设置中生成并设置环境变量 ADSPOWER_API_KEY');
|
||||||
|
console.error('4. 尝试在 AdsPower 中手动打开一次浏览器配置文件\n');
|
||||||
throw new Error(`[AdsPower] 启动失败: ${data.msg || JSON.stringify(data)}`);
|
throw new Error(`[AdsPower] 启动失败: ${data.msg || JSON.stringify(data)}`);
|
||||||
}
|
}
|
||||||
const wsEndpoint = data.data.ws && (data.data.ws.puppeteer || data.data.ws.selenium || data.data.ws.ws || data.data.ws);
|
const wsEndpoint = data.data.ws && (data.data.ws.puppeteer || data.data.ws.selenium || data.data.ws.ws || data.data.ws);
|
||||||
|
|||||||
@ -38,12 +38,21 @@ if not exist "node_modules\" (
|
|||||||
|
|
||||||
REM 设置环境变量
|
REM 设置环境变量
|
||||||
set ADSPOWER_USER_ID=k16x0qt2
|
set ADSPOWER_USER_ID=k16x0qt2
|
||||||
|
set ADSPOWER_API_KEY=
|
||||||
set DB_HOST=172.22.222.111
|
set DB_HOST=172.22.222.111
|
||||||
set DB_PORT=3306
|
set DB_PORT=3306
|
||||||
set DB_USER=auto-register-verdent
|
set DB_USER=auto-register-verdent
|
||||||
set DB_PASS=Qichen5210523
|
set DB_PASS=Qichen5210523
|
||||||
set DB_NAME=auto-register-verdent
|
set DB_NAME=auto-register-verdent
|
||||||
|
|
||||||
|
REM 提示检查
|
||||||
|
echo [注意] 请确保:
|
||||||
|
echo 1. AdsPower 已启动并登录
|
||||||
|
echo 2. 已在 AdsPower 中手动打开过配置文件一次
|
||||||
|
echo.
|
||||||
|
echo [启动] 3秒后开始运行...
|
||||||
|
timeout /t 3 /nobreak >nul
|
||||||
|
echo.
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo 启动配置:
|
echo 启动配置:
|
||||||
echo - AdsPower ID: %ADSPOWER_USER_ID%
|
echo - AdsPower ID: %ADSPOWER_USER_ID%
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user