C#HttpWebRequest获取人人网验证码


public void GetVerImage() 
{ HttpWebRequest request = null; 
HttpWebResponse response = null; 
string gethost = string.Empty; 
CookieContainer cc = new CookieContainer(); 
string Cookiesstr = string.Empty; 
try 
{
request = (HttpWebRequest)WebRequest.Create(" http://icode.renren.com/getcode.do?t=login&rnd=Math.random()"); 
request.CookieContainer = cc;
request.Method = "GET"; 
request.Accept = "application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"; 
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)"; 
request.ContentType = "image/jpeg"; 
response = (HttpWebResponse)request.GetResponse(); 
Stream responseStream = response.GetResponseStream(); 
Image original = Image.FromStream(responseStream); 
Bitmap bitMap = new Bitmap(original); 
this.pictureBox1.Image = bitMap; 
CookieCollection cook = response.Cookies; 
textBox1.Text = request.CookieContainer.GetCookieHeader(request.RequestUri); 
responseStream.Close(); 
} 


你可能感兴趣的:(.net,windows,String,Stream,null,textbox)