我想从this中获取数据页面并将其插入到我的 mssql 数据库中。如何使用 asp.net c# 读取这些数据? SehisID 是一个从 1 到 81 的值。
编辑: 我的代码如下。
for (int i = 1; i <= 81; i++)
{
HttpWebRequest rqst = (HttpWebRequest)WebRequest.Create("http://www.milliyet.com.tr/Secim2009/api/belediyelist.ashx?sehirid=" + i);
rqst.Method = "POST";
rqst.ContentType = "text/xml";
rqst.ContentLength = 0;
rqst.Timeout = 3000;
HttpWebResponse rspns = (HttpWebResponse)rqst.GetResponse();
form1.InnerHtml += rspns.ToString() + "<br>";
}
最佳答案
WebClient
是一种从网页获取字符串的简单方法:
WebClient client = new WebClient();
String downloadedString = client.DownloadString("http://www.milliyet.com.tr/Secim2009/api/belediyelist.ashx?sehirid=81");
关于c# - 如何从网页中获取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3354665/