내가 예를 들어에서 구글의 보안 문자를 표시하는 팝업 상자를 만들었습니다 : http://www.google.com/sorry/?continue=http://www.google.com/ajax/rd%3Fsky%3Deeuiphp%26ludocid%3D6083833001863340802%26rdu%3DCNzphIbM6rECFWkGtAodP3UAGQ%26sig%3DaY3%26q%3Dtandl%25C3%25A4kare%252Cg%25C3%25B6teborg%2BSweden
은 보낼 수 없습니다이 HttpWebRequest를
가 그때 내 프로그램 내에서 상자에 보안 문자를 입력하고 내 옆에 함수에 정보를 보낼를 아래에서 Google에 데이터를 제출해야합니다. 피들러 (Fiddler)와 함께 추적하려고했지만 잘못된 점을 파악할 수 없습니다. 요청은 다른 보안 문자 이미지를 반환합니다.
Fiddler에서 브라우저에 가서 GET 유형의 요청을 제출할 수 있지만 어떻게 데이터를 제출할 수 있습니까? 나는 내 POST를 GET으로 전환하는 등의 시도를했지만 항상 동일한 오류가 발생하며 다른 보안 문자 이미지가 표시됩니다.
어떤 아이디어가 잘못되었을 수 있습니까?
public string submitGoogleCaptcha(string html, string captchaCode)
{
CookieContainer cookieCont = new CookieContainer();
HttpWebRequest _wReq;
HttpWebResponse _wResp;
System.IO.StreamReader _sr;
System.Text.ASCIIEncoding _enc = new System.Text.ASCIIEncoding();
string continueValue = Regex.Match(html, @"<input type=""hidden"" name=""continue"" value=""\s*(.+?)\s*"">", RegexOptions.IgnoreCase).Groups[1].Value;
string idFromGoogle = Regex.Match(html, @"<input type=""hidden"" name=""id"" value=""\s*(.+?)\s*"">", RegexOptions.IgnoreCase).Groups[1].Value;
string _html = "";
string postData = "continue=" + continueValue + "&id=" + idFromGoogle + "&captcha=" + captchaCode + "&submit=Submit";
try
{
byte[] _data = _enc.GetBytes(postData);
_wReq = (HttpWebRequest)WebRequest.Create("http://www.google.com/sorry/Captcha?");
_wReq.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
_wReq.Referer = "http://www.google.com/sorry/?continue=" + HttpUtility.UrlEncode(continueValue);
_wReq.KeepAlive = true;
_wReq.Method = "POST";
_wReq.ContentType = "application/x-www-form-urlencoded";
_wReq.ContentLength = _data.Length;
_wReq.CookieContainer = cookieCont;
_wReq.AllowAutoRedirect = true;
_wReq.UserAgent = "Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
System.IO.Stream _outStream = _wReq.GetRequestStream();
_outStream.Write(_data, 0, _data.Length);
_outStream.Close();
_wResp = (HttpWebResponse)_wReq.GetResponse();
_sr = new System.IO.StreamReader(_wResp.GetResponseStream());
_html = _sr.ReadToEnd();
_sr.Close();
_wResp.Close();
}
catch (Exception ee)
{
}
return _html;
}
이 오류는 잘못된 URL을 제출하고 있음을 나타냅니다. – gwenda