极验验证通过 → 返回账号密码 + 库存数量
第一步:你的前端页面 — 加载极验,拿到参数
<!-- 在你的页面引入极验 SDK -->
<script src="https://static.geetest.com/v4/gt4.js"></script>
<button id="claimBtn" onclick="doClaim()">领取账号</button>
<script>
var CAPTCHA_ID = 'd6545edb20e9d3af0ba00c7549cd27c6';
var gtObj = null;
// 初始化极验
initGeetest4({
captchaId: CAPTCHA_ID,
product: 'bindbindbindbind' // 验证码直接弹出
}, function(obj) {
gtObj = obj;
obj.onSuccess(function() {
// 拿到极验返回的 4 个参数
var r = obj.getValidate();
var params = {
lot_number: r.lot_number,
captcha_output: r.captcha_output,
pass_token: r.pass_token,
gen_time: r.gen_time
};
// 发给你的后端
fetch('/your-api', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(params)
})
.then(function(res) { return res.json(); })
.then(function(data) {
if (data.success) {
alert('账号: ' + data.username + '\n密码: ' + data.password);
} else {
alert(data.message);
}
});
});
});
function doClaim() {
if (gtObj) gtObj.showCaptcha();
}
</script>
第二步:你的后端 — 收到参数后转发给我
import requests
from flask import Flask, request, jsonify
app = Flask(__name__)
MY_API = 'https://get.fzyidc.com/api.php'
@app.route('/your-api', methods=['POST'])
def claim():
data = request.get_json()
# 把前端拿到的极验参数转发给我的 API
resp = requests.post(MY_API, data={
'lot_number': data['lot_number'],
'captcha_output': data['captcha_output'],
'pass_token': data['pass_token'],
'gen_time': data['gen_time'],
})
return jsonify(resp.json())
<?php
$data = json_decode(file_get_contents('php://input'), true);
// 转发给我的 API
$ch = curl_init('https://get.fzyidc.com/api.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'lot_number' => $data['lot_number'],
'captcha_output' => $data['captcha_output'],
'pass_token' => $data['pass_token'],
'gen_time' => $data['gen_time'],
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
header('Content-Type: application/json');
echo $result;
const express = require('express');
const axios = require('axios');
const app = express();
app.use(express.json());
app.post('/your-api', async (req, res) => {
const { lot_number, captcha_output, pass_token, gen_time } = req.body;
const resp = await axios.post('https://get.fzyidc.com/api.php',
new URLSearchParams({ lot_number, captcha_output, pass_token, gen_time })
);
res.json(resp.data);
});
| 参数 | 来源 | 说明 |
|---|---|---|
| lot_number* | 极验自动 | 验证流水号 |
| captcha_output* | 极验自动 | 验证输出 |
| pass_token* | 极验自动 | 通过标识 |
| gen_time* | 极验自动 | 时间戳 |
obj.getValidate() 就能拿到 4 个参数