1

我试图复制一个站点帖子,如下所示: https ://www.usbank.com/cgi_w/cfm/personal/products_and_services/reoPropertiesReq.cfm

我只想发布任何状态以查看结果,因为它们最终会出现在电子邮件中。这是我的发布方法,它适用于其他网站上的登录等,所以我知道它有效

public HtmlDocument POST(string url, string postData)
    {//string myParameters = "param1=value1&param2=value2&param3=value3";

        HtmlDocument hdoc = new HtmlDocument();
        wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
        using (wc)
        {
            hdoc.LoadHtml(wc.UploadString(url, postData));
        }

        return hdoc;
    }

我像这样使用它:

HtmlDocument mainDoc = POST("https://www.usbank.com/cgi_w/cfm/personal/products_and_services/reoPropertiesReq.cfm",
            "selState=4&StateNM=Arizona");

但这似乎不正确。任何人都可以分析这个网站并确定它是我的代码还是缺少数据?

4

1 回答 1

1

前段时间我已经为我编写了此功能,希望对您有所帮助

    private void POST(string url, string data)
    {
        HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
        req.Method = "POST";
        req.Headers.Add(HttpRequestHeader.AcceptLanguage, "de-DE,de;q=0.8,en-US;q=0.7,en;q=0.3");

        req.Timeout = req.ReadWriteTimeout = 15000;

        ASCIIEncoding encoding = new ASCIIEncoding();
        byte[] dataBytes = encoding.GetBytes(data);
        req.ContentLength = dataBytes.Length;
        Stream stream = req.GetRequestStream();
        stream.Write(dataBytes, 0, dataBytes.Length);
        stream.Close();

        req.GetResponse();
    }
于 2012-12-18T13:52:46.210 回答