/// <summary> /// 采用httpwebrequest方式访问网络,根据传入的URl地址,得到响应的数据字符串。 /// </summary> /// <param name="objHttpItems">参数列表</param> /// <param name="cookie">自动维护的字符串cookie</param> /// <returns>HttpResults 为返回结果</returns> public HttpResults GetHtml(HttpItems objHttpItems, ref string cookie) { //调用专门读取数据的类 HttpResults res = GetHttpRequestData(objHttpItems); cookie = new XJHTTP().UpdateCookie(cookie, res.Cookie); res.Cookie = cookie; return(res); }
public static HttpResults RequestMethod(string url, string pdata, string method = "Post") { HttpHelpers helper = new HttpHelpers();//发起请求对象 HttpItems items = new HttpItems() { Url = url, Postdata = pdata, Method = method }; //请求设置对象 HttpResults hr = new HttpResults(); //请求结果 return(helper.GetHtml(items)); }
public static HttpResults RequestMethod(string type, string url, string pdata, SessionInfo sessionInfo, string method = "Post") { HttpItems items; CookieContainer cookieContainer = new CookieContainer(); cookieContainer.Add(new Cookie() { Name = sessionInfo.CookieID, Value = sessionInfo.CookieValue, Domain = sessionInfo.Domain }); HttpHelpers helper = new HttpHelpers();//发起请求对象 string contentType; string referer; string userAgent; if (type == "Bets") { contentType = "application/x-www-form-urlencoded;charset=UTF-8"; referer = "https://m.caikz99.com/lottery/K3/1407"; userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"; items = new HttpItems() { Url = url, Postdata = pdata, Method = method, Container = cookieContainer, ContentType = contentType, Referer = referer, UserAgent = userAgent }; //请求设置对象 } else { items = new HttpItems() { Url = url, Postdata = pdata, Method = method, Container = cookieContainer }; //请求设置对象 } HttpResults hr = new HttpResults();//请求结果 return(helper.GetHtml(items)); }
/// <summary> /// 读取返回对象中数据,并返回Image格式图片 /// </summary> /// <param name="hr">GetHtml后的请求结果</param> /// <returns></returns> public Image GetImg(HttpResults hr) { return(byteArrayToImage(hr.ResultByte)); }