想在代码中像AJAX一样访问一个URL,并对结果进行解析,可以使用以下代码实现:
string URL = "要访问的网址+参数";
WebClient client = new WebClient();
Stream data = client.OpenRead(URL);
StreamReader reader = new StreamReader(data);
string str = reader.ReadLine();
先using System.Net; 再WebClient w = new WebClient(); w.DownloadString(url)返回的就是网址为url的网页的内容string str2 = client.DownloadString(URL);
Label1.Text = str2;