Chat with us, powered by LiveChat
← Return to MyDisct Solver

Tencent CAPTCHA Token Solving

Solve Tencent CAPTCHA challenges programmatically. Tencent CAPTCHA is widely used on Chinese websites and applications for bot protection.

What is Tencent CAPTCHA?

Tencent CAPTCHA is a verification service provided by Tencent Cloud. It uses various challenge types including slider puzzles, click verification, and image selection. The solution returns a token containing ticket and randstr for verification.

Captcha Type

Use the following captcha type identifier in your API requests:

"type": "TENCENT_CAPTCHA_TOKEN"

Finding Captcha Parameters

To solve Tencent CAPTCHA, you need to find the siteKey (appId):

// Look for TencentCaptcha initialization in the page
var captcha = new TencentCaptcha('190014885', callback, options);

    

Request Format

POST /createTask

Request Parameters

Parameter Type Required Description
auth.token string required Your API key
captcha.type string required Must be "TENCENT_CAPTCHA_TOKEN"
captcha.metadata.siteUrl string required The URL where the captcha appears
captcha.metadata.siteKey string required Tencent CAPTCHA appId (CaptchaAppId)
captcha.payload.proxy object optional Proxy configuration (recommended for Chinese sites)

Example Request

JavaScript
const response = await fetch('https://solver-api.mydisct.com/createTask', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'apikey': 'YOUR_API_KEY'
  },
  body: JSON.stringify({
    auth: {
      token: 'YOUR_API_KEY'
    },
    context: {
      source: 'api',
      version: '1.0.0'
    },
    captcha: {
      type: 'TENCENT_CAPTCHA_TOKEN',
      metadata: {
        siteUrl: 'https://www.example.com/',
        siteKey: '190014885'
      },
      payload: {}
    }
  })
});

const data = await response.json();
console.log('Task ID:', data.task.id);

Response Format

Create Task Response (Processing)

{
  "success": true,
  "service": "MyDisct Solver",
  "message": "Task created successfully",
  "task": {
    "id": "MyDisctSolver_abc123",
    "status": "processing"
  }
}

Fetch Result Response (Completed)

{
  "success": true,
  "service": "MyDisct Solver",
  "message": "Captcha solved successfully",
  "task": {
    "id": "MyDisctSolver_abc123",
    "status": "completed",
    "result": {
      "token": "tr0344YjJASGmJGtohyWS_y6tJKiqVPIdFgl87vWlVaQoueR8D6DH28go-i-VjeassM31SXO7D0*|@KVN",
      "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
      "timestamp": "2025-11-26T12:00:15.000Z"
    }
  }
}

Response Fields

Field Type Description
result.token string The Tencent CAPTCHA token containing ticket and randstr separated by a pipe character.
result.user_agent string The exact user agent used during solving. Must be forwarded in all subsequent requests that use the generated token.
Using the Token

The token field contains a pipe-separated string in the format ticket|randstr. Split the token by the | character to extract the individual values and pass them to the callback function or backend verification.

Implementation Guide

Step 1: Extract siteKey from Page

// Find TencentCaptcha initialization
function getTencentSiteKey() {
  const scripts = document.querySelectorAll('script');
  for (const script of scripts) {
    const match = script.textContent.match(/new\s+TencentCaptcha\s*\(\s*['"](\d+)['"]/);
    if (match) {
      return match[1];
    }
  }
  return null;
}

const siteKey = getTencentSiteKey();
console.log('Tencent siteKey:', siteKey);

Step 2: Parse and Use the Token

const [ticket, randstr] = result.token.split('|');

// Use result.user_agent in subsequent requests
myCallbackFunction({
  ret: 0,
  ticket: ticket,
  randstr: randstr,
  appid: siteKey
});

await fetch('/api/verify-captcha', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'User-Agent': result.user_agent
  },
  body: JSON.stringify({
    ticket: ticket,
    randstr: randstr,
    appid: siteKey
  })
});

Python Example

Python
import requests
import time

def solve_tencent_captcha(site_url, site_key, api_key, proxy=None):
    payload = {}
    if proxy:
        payload['proxy'] = proxy

    # Step 1: Create task
    create_response = requests.post(
        'https://solver-api.mydisct.com/createTask',
        headers={
            'Content-Type': 'application/json',
            'apikey': api_key
        },
        json={
            'auth': {'token': api_key},
            'context': {'source': 'api', 'version': '1.0.0'},
            'captcha': {
                'type': 'TENCENT_CAPTCHA_TOKEN',
                'metadata': {
                    'siteUrl': site_url,
                    'siteKey': site_key
                },
                'payload': payload
            }
        }
    )

    create_data = create_response.json()
    if not create_data['success']:
        raise Exception(create_data['error']['message'])

    task_id = create_data['task']['id']

    # Step 2: Poll for result
    while True:
        time.sleep(5)
        result_response = requests.post(
            'https://solver-api.mydisct.com/fetchResult',
            headers={'Content-Type': 'application/json', 'apikey': api_key},
            json={'taskId': task_id}
        )
        result_data = result_response.json()
        if result_data['task']['status'] == 'completed':
            return result_data['task']['result']  # Contains token and user_agent
        elif result_data['task']['status'] == 'failed':
            raise Exception('Solving failed')

# Usage
result = solve_tencent_captcha(
    site_url='https://www.example.com/',
    site_key='190014885',
    api_key='YOUR_API_KEY'
)

ticket, randstr = result['token'].split('|')
print(f'Ticket: {ticket}')
print(f'Randstr: {randstr}')
print(f'User Agent: {result["user_agent"]}')

response = requests.post('https://www.example.com/api/verify',
    headers={'User-Agent': result['user_agent']},
    json={
    'ticket': ticket,
    'randstr': randstr,
    'appid': '190014885'
})

Best Practices

Recommendations
  • Make sure to extract the correct siteKey (appId) from the TencentCaptcha initialization
  • Forward the user_agent from the response in all subsequent requests that use the token
  • Consider using a Chinese proxy for better success rates on Chinese websites
  • Split the token by the pipe character (|) to extract ticket and randstr values
  • Tencent tokens expire after a few minutes, use them promptly

Common Issues

Issue: Invalid siteKey error

Solution: The siteKey (appId) must be a numeric string (e.g., "190014885"). Make sure you're extracting the correct value from the TencentCaptcha constructor call in the page source.

Issue: Token verification fails

Solution: Ensure you're splitting the token by the pipe character (|) and sending both ticket and randstr values separately. Some backends also require the user's IP address to match.

Issue: Slow solving on Chinese sites

Solution: For websites hosted in China, using a Chinese proxy can significantly improve solving speed and success rate.