如何从网页数据? [英] How to get data from web page?

查看:129
本文介绍了如何从网页数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从这个数据页面并将其插入到我的MSSQL数据库。我怎样才能读取asp.net C#这个数据? SehisID是从1到81的值。

编辑:
我的code如下。

 的for(int i = 1; I< = 81;我++)
{
    HttpWebRequest的RQST = (HttpWebRequest)WebRequest.Create(\"http://www.milliyet.com.tr/Secim2009/api/belediyelist.ashx?sehirid=\" + I);
    rqst.Method =POST;
    rqst.ContentType =文/ XML;
    rqst.ContentLength = 0;
    rqst.Timeout = 3000;    HttpWebResponse rspns =(HttpWebResponse)rqst.GetResponse();
    form1.InnerHtml + = rspns.ToString()+< BR>中;
}


解决方案

Web客户端是一个简单的方法来从一个网页的字符串:

  Web客户端的客户端=新的WebClient();
串downloadedString = client.DownloadString(http://www.milliyet.com.tr/Secim2009/api/belediyelist.ashx?sehirid=81);

I want to get the data from this page and insert it to my mssql database. How can I read this data with asp.net c#? SehisID is a value from 1 to 81.

EDIT: My code is below.

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 is an easy way to get a string from a web page:

WebClient client = new WebClient();
String downloadedString = client.DownloadString("http://www.milliyet.com.tr/Secim2009/api/belediyelist.ashx?sehirid=81");

这篇关于如何从网页数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆