我可以在Windows应用程序中而不是在网页中包含reCAPTCHA吗?

Pho*_*gan 1 .net c# windows recaptcha

我想将它集成到Windows应用程序中.我正在使用Visual Studio 2010,它是一个C#Windows窗体应用程序.

PaR*_*RaJ 5

    public static Image DownloadReCaptcha(string key, ref string challenge)
    {

        try
        {
            WebClient client = new WebClient();
            string response = client.DownloadString(string.Format("http://api.recaptcha.net/challenge?k={0}", key));

            Match match = Regex.Match(response, "challenge : '(.+?)'");

            if (match.Captures.Count == 0)
            {
                challenge = null;
                return null;
            }

            challenge = match.Groups[1].Value;
            if (File.Exists("captcha.jpg")) File.Delete("captcha.jpg");
            client.DownloadFile(string.Format("http://www.google.com/recaptcha/api/image?c={0}", challenge),
                                "captcha.jpg");
            return Image.FromFile("captcha.jpg");

        }
        catch (Exception)
        {
            challenge = null;
            return null;
        }
    }
Run Code Online (Sandbox Code Playgroud)

使用它像:

string challenge = null; // you will need this to submit captcha answer
pictureBox1.Image = DownloadReCaptcha("reCaptcha site key", ref challenge);
Run Code Online (Sandbox Code Playgroud)

如何找到钥匙?

在网页的HTML源代码中,你会发现类似的内容

<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LexLsMSAAAAABUuI6bvUYfxaumgcu0vGiEFotDA"></script>

key = 6LexLsMSAAAAABUuI6bvUYfxaumgcu0vGiEFotDA