Solving GeeTest
- Find the following GeeTest captcha parameters on the target website (usually you can find them inside
initGeetest
function):
gt
- public website key (static)
challenge
- dynamic challenge key
api_server
- API domain (optional)
Important: you should get a new challenge value for each request to our API. Once captcha was loaded on the page the challenge value becomes invalid. You should inspect requests made to the website when page is loaded to identify a request that gets a new challenge value. Then you should make such request each time to get a valid challenge value.
Send these parameters to 2Captcha API.
If captcha is already solved server will return the response in JSON. The response contains three values: challenge, validate and seccode:
{
"challenge": "1a2b3456cd67890e12345fab678901c2de",
"validate": "09fe8d7c6ba54f32e1dcb0a9fedc8765",
"seccode": "12fe3d4c56789ba01f2e345d6789c012|jordan"
}
- Use the values received from our API to submit your request to the target website placing the values into corresponding request fields:
geetest_challenge
geetest_validate
geetest_seccode
- Click on "Check" button to submit the form.
PHP
// https://github.com/2captcha/2captcha-php
require(__DIR__ . '/../src/autoloader.php');
$solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');
try {
$result = $solver->geetest([
'gt' => 'f2ae6cadcf7886856696502e1d55e00c',
'apiServer' => 'api.geetest.com',
'challenge' => '12345678abc90123d45678ef90123a456b',
'url' => 'https://2captcha.com/demo/geetest',
]);
} catch (\Exception $e) {
die($e->getMessage());
}
die('Captcha solved: ' . $result->code);
Java
// https://github.com/2captcha/2captcha-java
package examples;
import com.twocaptcha.TwoCaptcha;
import com.twocaptcha.captcha.GeeTest;
public class GeeTestExample {
public static void main(String[] args) {
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
GeeTest captcha = new GeeTest();
captcha.setGt("f2ae6cadcf7886856696502e1d55e00c");
captcha.setApiServer("api.geetest.com");
captcha.setChallenge("12345678abc90123d45678ef90123a456b");
captcha.setUrl("https://2captcha.com/demo/geetest");
try {
solver.solve(captcha);
System.out.println("Captcha solved: " + captcha.getCode());
} catch (Exception e) {
System.out.println("Error occurred: " + e.getMessage());
}
}
}
C#
// https://github.com/2captcha/2captcha-csharp
using System;
using System.Linq;
using TwoCaptcha.Captcha;
namespace TwoCaptcha.Examples
{
public class GeeTestExample
{
public void Main()
{
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
GeeTest captcha = new GeeTest();
captcha.SetGt("f2ae6cadcf7886856696502e1d55e00c");
captcha.SetApiServer("api.geetest.com");
captcha.SetChallenge("12345678abc90123d45678ef90123a456b");
captcha.SetUrl("https://2captcha.com/demo/geetest");
try
{
solver.Solve(captcha).Wait();
Console.WriteLine("Captcha solved: " + captcha.Code);
}
catch (AggregateException e)
{
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
}
}
}
}
Python
# https://github.com/2captcha/2captcha-python
import sys
import os
import requests
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
from twocaptcha import TwoCaptcha
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
solver = TwoCaptcha(api_key)
resp = requests.get("http://demo.2captcha.com/?type=geetest")
challenge = resp.content.decode('utf-8').split(';')[0]
try:
result = solver.geetest(gt='f3bf6dbdcf7886856696502e1d55e00c',
apiServer='api.geetest.com',
challenge=challenge,
url='https://2captcha.com/demo/geetest')
except Exception as e:
sys.exit(e)
else:
sys.exit('solved: ' + str(result))
Go
// https://github.com/2captcha/2captcha-go
package main
import (
"fmt"
"log"
"github.com/2captcha/2captcha-go"
)
func main() {
client := api2captcha.NewClient("API_KEY")
cap := api2captcha.GeeTest{
GT: "f2ae6cadcf7886856696502e1d55e00c",
ApiServer: "api.geetest.com",
Challenge: "12345678abc90123d45678ef90123a456b",
Url: "https://2captcha.com/demo/geetest",
}
code, err := client.Solve(cap.ToRequest())
if err != nil {
log.Fatal(err);
}
fmt.Println("code "+code)
}
C++
// https://github.com/2captcha/2captcha-cpp
#include <cstdio>
#include "curl_http.hpp"
#include "api2captcha.hpp"
int main (int ac, char ** av)
{
api2captcha::curl_http_t http;
http.set_verbose (true);
api2captcha::client_t client;
client.set_http_client (&http);
client.set_api_key (API_KEY);
api2captcha::geetest_t cap;
cap.set_gt ("f2ae6cadcf7886856696502e1d55e00c");
cap.set_api_server ("api.geetest.com");
cap.set_challenge ("12345678abc90123d45678ef90123a456b");
cap.set_url ("https://2captcha.com/demo/geetest");
try
{
client.solve (cap);
printf ("code '%s'\n", cap.code ().c_str ());
}
catch (std::exception & e)
{
fprintf (stderr, "Failed: %s\n", e.what ());
}
return 0;
}
