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;
}
QQ群:1022985150 VX:kklldog 一起探讨学习.NET技术
作者:Agile.Zhou(kklldog)
出处:http://www.cnblogs.com/kklldog/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。