[C#] 纯文本查看 复制代码 public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnPost_Click(object sender, EventArgs e)
{
PostData();
}
public string PostData()
{
string Imgurl = "";
HttpHelper http = new HttpHelper();
string url = "http://groupon.sdo.com/createOrder.aspx?grouponId=546";
url = "https://cas.sdo.com/authen/staticLogin.jsonp?callback=staticLogin_JSONPMethod&inputUserId=账号&password=密码&appId=723&areaId=999&serviceUrl=http%3A%2F%2Fgroupon.sdo.com%2FLoginCallback.aspx%3FReturnUrl%3D%2FcreateOrder.aspx%3FgrouponId%3D546&productVersion=v5&frameType=3&locale=zh_CN&version=21&tag=20&authenSource=2&productId=2&customSecurityLevel=2&autoLoginFlag=0&_=1474878416934";
HttpItem item = new HttpItem()
{
URL = url,//URL 必需项
Method = "GET",//URL 可选项 默认为Get
Timeout = 100000,//连接超时时间 可选项默认为100000
ReadWriteTimeout = 30000,//写入Post数据超时时间 可选项默认为30000
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
Cookie = "",//字符串Cookie 可选项
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",//用户的浏览器类型,版本,操作系统 可选项有默认值
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",//返回类型 可选项有默认值
Referer = url,//来源URL 可选项
};
HttpResult result = http.GetHtml(item);
string html = result.Html;
string cookie = result.Cookie;
string htmljson = html.Replace("staticLogin_JSONPMethod(", "").TrimEnd(')');
LoginJson lgjson = Newtonsoft.Json.JsonConvert.DeserializeObject<LoginJson>(htmljson);
Imgurl = lgjson.data.checkCodeUrl;
GetImg(Imgurl);
return Imgurl;
}
//刷新验证码
private void btnImg_Click(object sender, EventArgs e)
{
string imgurl = txtUrl.Text;
GetImg(imgurl);
}
private void GetImg(string imgsrc)
{
Image pic = Image.FromStream(WebRequest.Create(imgsrc).GetResponse().GetResponseStream());
picBox.Image = pic;
}
}
public class LoginJson
{
public string return_code { get; set; }
public string error_type { get; set; }
public string return_message { get; set; }
public LoginData data { get; set; }
}
public class LoginData
{
public string appId { get; set; }
public string areaId { get; set; }
public string checkCodeUrl { get; set; }
public string guid { get; set; }
public string imagecodeType { get; set; }
public string isNeedFullInfo { get; set; }
public string nextAction { get; set; }
}
我执行到获取验证码的时候他那边的请求有点看不懂他的验证码是怎么传进行登录 求解答 |