Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Specialized;
- using System.IO;
- using System.Net;
- using System.Text;
- using System.Threading;
- namespace WraithSubmitter
- {
- class CaptchaSolveTextCaptcha
- {
- public static string SolveTextCaptcha(string apiKey, string theQuestion, out string result) {
- string postUrl = "https://2captcha.com/in.php";
- var response = string.Empty;
- result = string.Empty;
- try
- {
- using (var client = new WebClient())
- {
- var values = new NameValueCollection
- {
- ["key"] = apiKey,
- ["method"] = "POST",
- ["textcaptcha"] = theQuestion
- };
- var res = client.UploadValues(postUrl, values);
- response = Encoding.Default.GetString(res);
- }
- //Helpers.ReturnMessage(apiKey + " > " + theQuestion + " > " + result);
- //Helpers.ReturnMessage("Response: " + response);
- if (response.Substring(0, 3) == "OK|")
- {
- string captchaID = response.Remove(0, 3);
- for (int i = 0; i < 24; i++)
- {
- WebRequest getAnswer = WebRequest.Create("https://2captcha.com/res.php?key=" + apiKey + "&action=get&id=" + captchaID);
- using (WebResponse answerResp = getAnswer.GetResponse())
- using (StreamReader answerStream = new StreamReader(answerResp.GetResponseStream()))
- {
- string answerResponse = answerStream.ReadToEnd();
- if (answerResponse.Length < 3)
- {
- result = answerResponse;
- } else {
- if (answerResponse.Substring(0, 3) == "OK|")
- {
- result = answerResponse.Remove(0, 3);
- break;
- } else if (answerResponse != "CAPCHA_NOT_READY"){
- //result = answerResponse;
- //return result;
- }
- }
- }
- Thread.Sleep(5000);
- }
- }
- } catch (Exception ex) {
- Helpers.ReturnMessage("TEXT CAPTCHA:\n\n" + ex.Message);
- }
- return result;
- }
- } // End.
- } // End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement