看板 C_Sharp 關於我們 聯絡資訊
大家好: 最近手癢想寫個MLB的數據分析軟體,但是用httpwebrequest去抓www.mlb.com的字串時, 卻抓不到字串,但是以www.yahoo.com.tw為例,卻抓的到字串,目前尚未找出原因 請有過同樣情況的鄉民們解答 ^^ code string Syslog; string URL = "http://WWW.MLB.COM"; HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(URL); HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); Stream msgstream = myHttpWebResponse.GetResponseStream(); Encoding encode = System.Text.Encoding.GetEncoding("utf-8"); StreamReader readStream = new StreamReader(msgstream, encode); Syslog = readStream.ReadToEnd(); readStream.Close(); MessageBox.Show(Syslog); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.127.38.114 ※ 編輯: MacPerson 來自: 122.127.38.114 (02/20 15:29)
pico2k:有檢查responseCode的數值嗎? 02/20 16:09
MacPerson:我是把傳回來的值暫時show在messagebox 但是裡面沒東西 02/20 16:11
MacPerson:已解決 感恩 02/20 17:12