Loading

ASP.NET 获取维基百科研究记录

1.API:http://zh.wikipedia.org/w/api.php

2.获取一个词条的内容:http://zh.wikipedia.org/w/api.php?action=parse&format=xml&page=keyWord

这个url获取的是一个XML,其中text节点包含的就是关键字对应页面的HTML。具体各个参数什么意思参考API说明。

3.查询 返回跟关键字匹配的若干词条的XML:http://zh.wikipedia.org/w/api.php?action=query&list=search&srwhat=text&format=xml&srsearch=keyword

4.HttpWebRequest获取Stream:

 

            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
            webRequest.UserAgent = "Mozilla/5.0";
            HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
            if (webResponse.StatusCode == HttpStatusCode.OK)
            {
                return webResponse.GetResponseStream();
            }

5.简繁体转换:

引用vb runtime 后

     private string StrConvent(string text, Microsoft.VisualBasic.VbStrConv type)
        {
            string str = Microsoft.VisualBasic.Strings.StrConv(text, type, 0);
            return str;

        } 

 

posted @ 2011-07-19 17:31  Agile.Zhou  阅读(387)  评论(0编辑  收藏  举报