public void TestMethod1() { var dicPostData = new Dictionary <string, string>(); dicPostData.Add("username", "skynetfy"); dicPostData.Add("password", "3447983"); dicPostData.Add("execution", "e4s1"); dicPostData.Add("_eventId", "submit"); dicPostData.Add("lt", "LT-47742-zooQnRZrkzqiz4KrTF61Xbdw1916Qx"); HttpResponseParameter responseParameter = httpProvider.Excute(new HttpRequestParameter { Url = "http://passport.csdn.net/ajax/accounthandler.ashx?t=log&u=skynetfy&p=3447983&remember=0&callback=csdn.login_back&r=1451371217211", IsPost = false, Cookie = SessionCookie, Accept = "*/*", UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36", RefererUrl = "http://download.csdn.net/download/sy_05/9381944" }); SessionCookie = responseParameter.Cookie; var response = httpProvider.Excute(new HttpRequestParameter { Url = "http://dl.download.csdn.net/down11/20151229/eaa6473fcb255ba527cef1ad0ee1ae1e.rar?response-content-disposition=attachment%3Bfilename%3DCCC.rar&OSSAccessKeyId=9q6nvzoJGowBj4q1&Expires=1451375339&Signature=YYHS%2FTdgHSqv9WFq9ek2zGK2OlU%3D", IsPost = false, Cookie = SessionCookie, Accept = "*/*", UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36", }); }
/// <summary> /// 获取登录的Cookie /// </summary> void GetLoginSessionCookie() { var httpResponse = httpProvider.Excute(new HttpRequestParameter() { Url = "http://passport.jikexueyuan.com/sso/login", IsPost = false }); SessionCookie = httpResponse.Cookie; }
private void GetSessionCookie() { HttpResponseParameter responseParameter = httpProvider.Excute(new HttpRequestParameter { Url = "http://download.csdn.net/detail/sy_05/9381944", IsPost = false }); SessionCookie = responseParameter.Cookie; }
/// <summary> /// 获取登录的Cookie /// </summary> void GetLoginSessionCookie() { var httpResponse = HttpProvider.Excute(new HttpRequestParameter() { Url = "https://kyfw.12306.cn/otn/login/init", IsPost = false }); SessionCookie = httpResponse.Cookie; }
public static bool CheckUserLogin(HttpCookieType sessionCookie) { var dicPostData2 = new Dictionary <string, string>(); dicPostData2.Add("_json_att", ""); HttpResponseParameter responseParameter2 = new HttpProvider().Excute(new HttpRequestParameter { Url = _12306UrlConfig.CheckLoginUrl, IsPost = true, Parameters = dicPostData2, Cookie = sessionCookie }); HttpJsonResultEntity <LoginCheckResult> logResult = JsonConvert.DeserializeObject <HttpJsonResultEntity <LoginCheckResult> >(responseParameter2.Body); return(logResult.Data.Flag); }
public HttpCookieType UserLogin(Dictionary <string, string> postData, HttpCookieType sessionCookie) { var _sessionCookie = new HttpCookieType(); _sessionCookie = sessionCookie; HttpResponseParameter responseParameter = httpProvider.Excute(new HttpRequestParameter { Url = "https://kyfw.12306.cn/otn/login/loginAysnSuggest", IsPost = true, Parameters = postData, Cookie = sessionCookie }); _sessionCookie.CookieCollection.Add(responseParameter.Cookie.CookieCollection); _sessionCookie.CookieString = _sessionCookie.CookieString + "," + responseParameter.Cookie.CookieString; return(_sessionCookie); }
public static HttpCookieType ShowRandCode(HttpCookieType sessionCookie, Image viefCode) { var SessionCookie = new HttpCookieType(); SessionCookie = sessionCookie; //GetSessionCookie(); var request = new HttpRequestParameter(); request.Url = string.Format(_12306UrlConfig.RandCodeUrl, DateTime.Now.ToString("yyyyMMddHHmmsss")); request.ResponseEnum = HttpResponseEnum.Stream; request.Cookie = sessionCookie; request.StreamAction = x => { MemoryStream ms = new MemoryStream(); byte[] buffer = new byte[1024]; while (true) { int sz = x.Read(buffer, 0, buffer.Length); if (sz == 0) { break; } ms.Write(buffer, 0, sz); } ms.Position = 0; BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.StreamSource = new MemoryStream(ms.ToArray()); bmp.EndInit(); viefCode.Source = bmp; ms.Close(); }; var response = new HttpProvider().Excute(request); SessionCookie.CookieCollection.Add(response.Cookie.CookieCollection); SessionCookie.CookieString = SessionCookie.CookieString + "," + response.Cookie.CookieString; return(sessionCookie); }