作者MacPerson (Gary)
看板C_Sharp
标题[问题] httpwebrequest
时间Sun Feb 20 15:28:30 2011
大家好:
最近手痒想写个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)
1F:→ pico2k:有检查responseCode的数值吗? 02/20 16:09
2F:→ MacPerson:我是把传回来的值暂时show在messagebox 但是里面没东西 02/20 16:11
3F:→ MacPerson:已解决 感恩 02/20 17:12