HTTPwebrequest,Json,填充在线文本框

时间:2013-12-20 18:45:10

标签: c# json httpwebrequest

我现在第一次使用HTTPWebRequests,我正试着全力以赴。我正在尝试填充此网站http://treasurer.maricopa.gov/Parcel/TaxReceipt.aspx上的“开始日期”文本框。我使用Fiddler来查找从POST返回的令人难以置信的长Json查询。 (如果需要,我会发布整个事情)......但我注意到最后一部分是我追求的

"............,"StartDate":"1/1/2013","EndDate":"12/31/2013"}}

到目前为止,这是我正在使用的功能,但result没有任何变化(所以就像你刚刚访问我首次发布的网站一样)

 public static void json(string url)
        {

            var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            httpWebRequest.ContentType = "text/json";
            httpWebRequest.Method = "POST";
            httpWebRequest.CookieContainer = cookieJar;           
            //httpWebRequest.Accept = "text/html, application/xhtml+xml, */*";
            httpWebRequest.Headers.Add("Accept-Language: en-US");
            httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW65; Trident/7.0; MAM5; rv:11.0) like Gecko";
            httpWebRequest.Headers.Add("Accept-Encoding: gzip, deflate");
            //httpWebRequest.Referer = url4;

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = @"{StartDate: 1/1/2013}, {EndDate: 12/13/2013}";

                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                }
            }

0 个答案:

没有答案