const axios = require('axios');
const apiUrl = 'https://api.kuaishibie.cn/predict';

const getKaptcha = async (base64data) => {
    try {
        const response = await axios.post(apiUrl, {
            username: 'Pchen0', // 用户名
            password: 'Yx3ud937', // 密码
            typeid: '3',
            image: base64data
        });

        const data = response.data;
        if (data.success) {
            const { result } = data.data;
            return result;
        } else {
            console.error(data.message);
            throw new Error(data.message);
        }
    } catch (error) {
        console.error('请求失败:', error.message);
        throw error;
    }
};

module.exports = getKaptcha;
