zoukankan      html  css  js  c++  java
  • C#.net模拟提交表单POST

    方法一、
    System.Net.WebClient WebClientObj         = new System.Net.WebClient();
        System.Collections.Specialized.NameValueCollection PostVars   = new System.Collections.Specialized.NameValueCollection();
        PostVars.Add("A1","0");
        PostVars.Add("A2","0");
        PostVars.Add("A3","000");

        try
        {
         byte[] byRemoteInfo    = WebClientObj.UploadValues("http://www.lovezhao.com/vote.asp","POST",PostVars);
         //下面都没用啦,就上面一句话就可以了
         string sRemoteInfo    = System.Text.Encoding.Default.GetString(byRemoteInfo);  
         //这是获取返回信息
         richTextBox_instr.Text   += sRemoteInfo;
        }
        catch
        {}



    方法二、
    string url = "网址";
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
    string s = "要提交的数据";
    byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes (LoginInfo);
    req.Method = "POST";
    req.ContentType = "application/x-www-form-urlencoded";
    req.ContentLength = requestBytes.Length;
    Stream requestStream = req.GetRequestStream();
    requestStream.Write(requestBytes,0,requestBytes.Length);
    requestStream.Close();
    HttpWebResponse res = (HttpWebResponse)req.GetResponse();
    StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
    string backstr = sr.ReadToEnd(); Response.Write(line); sr.Close(); res.Close();
  • 相关阅读:
    [NOIP2018校模拟赛]T2矩阵分组 Matrix
    [NOIP2018校模拟赛]T1聚会 party
    python写一个邮箱伪造脚本
    python抢火车票的脚本
    git的使用
    python写一个翻译的小脚本
    python写的一个集合
    python调用metasploit里的MS-17-010模块进行漏洞攻击
    ssh爆破篇
    python查询完结篇
  • 原文地址:https://www.cnblogs.com/Love/p/1792280.html
Copyright © 2011-2022 走看看