c#带cookie 的get请求

private string HttpGetData(string url, string cookies)

        {

            HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);

            myRequest.Headers.Add("cookie", cookies);

            myRequest.Method = "GET";

            HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();

            StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);

            string content = reader.ReadToEnd();

            reader.Close();

            return content;

        }
label1.Text = HttpGetData(url, cookie);

 

你可能感兴趣的:(C#)