代码如下: url="http://active.coupon.jd.com/ilink/couponActiveFront/front_index.action?key=6bafba67712344b8be108233f2eae693&roleId=1058050&to=sale.jd.com/act/xqidlajcqxm.html";
cookie 为登录cookie。 不知道怎么输入验证码都是错误啊。。。
[C#] 纯文本查看 复制代码 HttpHelper helper = new HttpHelper();
HttpResult result = new HttpResult();
HttpItem itm = new HttpItem()
{
URL = url,
KeepAlive = true,
Method = "GET",
Cookie = cookie,
};
itm.Cookie = cookie;
result = helper.GetHtml(itm);
string errmsg = Regex.Match(result.Html, "<h1 class=\"ctxt02\"><s class=\"icon(.*?)/s>([^<]*)").Groups["2"].Value.ToString();
if (errmsg.Trim() == "")
{
string gourl = Regex.Match(result.Html, "gotoUrl = '([^']*)").Groups["1"].Value.ToString();
string key = Regex.Match(result.Html, "key = '([^']*)").Groups["1"].Value.ToString();
string roolid = Regex.Match(result.Html, "roleId = '([^']*)").Groups["1"].Value.ToString();
string to = Regex.Match(result.Html, "to = '([^']*)").Groups["1"].Value.ToString();
string csrfStr = Regex.Match(result.Html, "csrfStr = '([^']*)").Groups["1"].Value.ToString();
string key3d = Regex.Match(result.Html, "key3d = '([^']*)").Groups["1"].Value.ToString();
itm.URL = Regex.Match(result.Html, "var url3d = '([^']*)").Groups["1"].Value.ToString() + key3d + "&_t="+GetTime();
itm.Method = "GET";
itm.ResultType = ResultType.Byte;
result = helper.GetHtml(itm);
string code = "";
if (result.StatusCode == HttpStatusCode.OK)
{
pictureBox1.Image = byteArrayToImage(result.ResultByte);
waitment.WaitOne();
code = textBox1.Text.Trim();
textBox1.Text = "";
pictureBox1.Image = null;
}
string sumiturl = gourl + "verifyCode="+ code + "&key=" + key + "&roleId=" + roolid+ "&to=" + to + "&csrfStr=" + csrfStr;;
itm.URL = sumiturl;
itm.Method = "GET";
itm.ContentType = "";
result = helper.GetHtml(itm);
|