Re: [問題] 請問使用POST的問題

看板C_Sharp作者 (huge)時間16年前 (2008/04/11 00:04), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
<吃光光></吃光光> 雖然還是不曉得前面的方式錯誤在哪,不過已經找到解決方法了 string SearchPage = @"http://www.ticket.com.tw/search.asp"; string UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3"; NameValueCollection postArguments = new NameValueCollection(); postArguments.Add("KeyWord", ""); postArguments.Add("TypeRead", HttpUtility.HtmlEncode("0,所有藝文(不含電影, 套票)")); postArguments.Add("SelArea", HttpUtility.HtmlEncode("0,不限地區")); postArguments.Add("SelYear", "0"); postArguments.Add("SelMonth", "0"); postArguments.Add("SelDate", "0"); postArguments.Add("SqlServerName", "192.168.100.200"); WebClient webClient = new WebClient(); webClient.Headers[HttpRequestHeader.UserAgent] = UserAgent; webClient.Encoding = Encoding.GetEncoding("big5"); byte[] bytes = webClient.UploadValues(SearchPage, postArguments); string result = Encoding.GetEncoding("big5").GetString(bytes); 最後的result就是該頁的資訊了 ^^ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 124.10.5.203

04/09 15:41, , 1F
謝謝啦
04/09 15:41, 1F
文章代碼(AID): #17_Zga5y (C_Sharp)
文章代碼(AID): #17_Zga5y (C_Sharp)