截图:
try
{
HttpWebRequest Req = (HttpWebRequest)WebRequest.Create(url);
//发送方式设为Post
Req.Method = "POST";
Req.Accept = "text/html, application/xhtml+xml, */*";
byte[] bytes = Encoding.UTF8.GetBytes(data);
Req.ContentLength = bytes.Length;
Req.ContentType = "application/x-www-form-urlencoded"; // 使用POST时必须加上
//尝试
Req.ReadWriteTimeout = 5000;
//
using (Stream requestStream = Req.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
}
HttpWebResponse Resp = (HttpWebResponse)Req.GetResponse();
Stream Strm = Resp.GetResponseStream();
StreamReader Rdr = new StreamReader(Strm, System.Text.Encoding.UTF8);
string tmp = Rdr.ReadToEnd();
//提取后释放资源
Rdr.Close();
Strm.Close();
Resp.Close();
return tmp;
}
catch (Exception ex)
{
return ex.Message.ToString() ;
}