我的获取页面需要cookie,不需要的可以去掉;
GET的方法:
代码如下:
/// <summary>
/// 获取URL访问的HTML内容 获取https 页面的
/// </summary>
/// <param name="Url">URL地址</param>
/// <returns>HTML内容</returns>
public static string GetWebContent(string Url, CookieContainer cookieContainer)
{
string strResult = "";
try
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
request.CookieContainer = cookieContainer;
request.Timeout = 30000;
request.Headers.Set("Pragma", "no-cache");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream streamReceive = response.GetResponseStream();
Encoding encoding = Encoding.GetEncoding("utf-8");
StreamReader streamReader = new StreamReader(streamReceive, encoding);
strResult = streamReader.ReadToEnd();
}
catch
{
}
return strResult;
}
POST的方法:
代码如下:
/// <summary>
/// post提交数据到https
新闻热点
疑难解答
图片精选