ASP.NET 调用百度搜索引擎的代码
更新时间:2009年11月12日 22:51:49 作者:
ASP.NET 调用百度搜索引擎的代码,需要的朋友可以参考下。
百度搜索引擎提供了一段嵌入到页面中的代码
<form action="http://www.baidu.com/baidu" target="_blank">
<table><tr><td>
<input name=tn type=hidden value=baidu>
<input type=text name=word size=80>
<input type=hidden name=ie value="UTF-8">
<input type="submit" style="background:url(images/searchicon.gif) no-repeat; border:0; width:76px; height:26px; cursor:pointer" value="搜索">
</td></tr></table>
</form>
但在使用中由于我的页面时UTF-8的
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
所以我必须在百度给出的代码中加上这句
<input type=hidden name=ie value="UTF-8">
这个是第一部分,第二部分,我需要配置搜索条下的热门词汇,点击后直接进入搜索结果,代码如下
HtmlTableCell searchText = new HtmlTableCell();
searchText.InnerHtml = string.Format("<a href=\"http://www.baidu.com/baidu?tn=baidu&word={0}&ie=UTF-8\" target=\"_blank\">{0}</a>|", dt.Rows[i]["SearchText"].ToString());
tr_search.Cells.Add(searchText);
<form action="http://www.baidu.com/baidu" target="_blank">
<table><tr><td>
<input name=tn type=hidden value=baidu>
<input type=text name=word size=80>
<input type=hidden name=ie value="UTF-8">
<input type="submit" style="background:url(images/searchicon.gif) no-repeat; border:0; width:76px; height:26px; cursor:pointer" value="搜索">
</td></tr></table>
</form>
但在使用中由于我的页面时UTF-8的
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
所以我必须在百度给出的代码中加上这句
<input type=hidden name=ie value="UTF-8">
这个是第一部分,第二部分,我需要配置搜索条下的热门词汇,点击后直接进入搜索结果,代码如下
HtmlTableCell searchText = new HtmlTableCell();
searchText.InnerHtml = string.Format("<a href=\"http://www.baidu.com/baidu?tn=baidu&word={0}&ie=UTF-8\" target=\"_blank\">{0}</a>|", dt.Rows[i]["SearchText"].ToString());
tr_search.Cells.Add(searchText);
相关文章
Asp.net静态方法之Grid转DataTable方法实现步骤
GridView绑定DataTable后,如何获取GridView绑定后显示的值,在项目需求的背景下写了一个静态方法,经过在项目中的使用,bug的修复,较为稳定2013-04-04
.net6环境下使用RestSharp请求GBK编码网页乱码的解决方案
这篇文章介绍了.net6环境下使用RestSharp请求GBK编码网页乱码的解决方案,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2021-12-12
验证用户必选CheckBox控件与自定义验证javascript代码
CheckBox控件,由于它的值是选择与非选择。因此在提交数据时,想让用户必须选择CheckBox,普通情况之下,不好做验证;但我们可以使用asp:CustomValidator来验证,不过还得写自定义验证Javascript代码2013-01-01
ASP.NET从客户端中检测到有潜在危险的request.form值的3种解决方法
这篇文章主要介绍了ASP.NET从客户端中检测到有潜在危险的request.form值的3种解决方法,这是ASP.NET开发中一个比较常见的经典的问题,需要的朋友可以参考下2015-01-01


最新评论