zoukankan      html  css  js  c++  java
  • .NET (c#) 模拟 Cookie

    string postData = "uUsername=avoid&uPassword=123456";
                        ASCIIEncoding encoding = new ASCIIEncoding();
                        byte[] data = encoding.GetBytes(postData);

                        request = (HttpWebRequest)WebRequest.Create(sUrl);
                        request.Method = "POST";
                        request.ContentType = "application/x-www-form-urlencoded";
                        request.ContentLength = data.Length;
                        Stream newStream = request.GetRequestStream();
                        newStream.Write(data, 0, data.Length);

                        newStream.Close();
                       
                        request.CookieContainer = cc;
                       
                        response = (HttpWebResponse)request.GetResponse();
                        cc.Add(response.Cookies);
                        stream = response.GetResponseStream();
                        sHtml = new StreamReader(stream, System.Text.Encoding.Default).ReadToEnd();
            private CookieContainer cc = new CookieContainer();

  • 相关阅读:
    在python中处理XML
    正则表达式
    python 反射
    python模块概况,json/pickle,time/datetime,logging
    python装饰器
    python3内置函数详解
    python函数,lambda表达式,三目运算,列表解析,递归
    python数据类型及其常用方法
    python3的文件操作
    初识Docker
  • 原文地址:https://www.cnblogs.com/kenter/p/1599606.html
Copyright © 2011-2022 走看看