百度 和 谷歌 的站内搜索引擎代码

网上曾有过两段Google和百度站内搜索的代码,如下(注意:代码中的“网站地址”要去掉http://

 <!--Google站内搜索开始--> 

<form method=get action="http://www.google.com/search"> 

<input type=text name=q> 

<input type=submit name=btnG value="Google 搜索"> 

<input type=hidden name=ie value=GB2312> 

<input type=hidden name=oe value=GB2312> 

<input type=hidden name=hl value=zh-CN> 

<input type=hidden name=domains value="网站地址"> 

<input type=hidden name=sitesearch value="网站地址"> 

</form> 

<!--Google站内搜索结束--> 

 

<!--Baidu站内搜索开始--> 

<form action="http://www.baidu.com/baidu"> 

<input type=text name=word> 

<input type="submit" value="Baidu 搜索"> 

<input name=tn type=hidden value="bds"> 

<input name=cl type=hidden value="3"> 

<input name=ct type=hidden value="2097152"> 

<input name=si type=hidden value="网站地址"> 

</form> 

<!--Baidu站内搜索结束--> 

 

试用了一下,由于博客编码或者少代码的关系,可能出现以下两个问题。

 

1、出现乱码的解决方法:在form表单内添加如下代码(如果是Google的话,把代码里的GB2312改成UTF-8就可以了)

 <input type=hidden name=ie value="UTF-8"> 

 

2、搜索结果无法在新页面显示的解决方法:将第一行改为如下代码

 <form action="http://www.baidu.com/baidu" target="_blank"> 

 

下面是Google和百度Javascript版站内搜索代码(未测试)

 <!--Google站内搜索开始--> 

<script type="text/javascript">   

function googlesearch () {  

var wq=document.getElementsByName("wq")[0].value;  

var link="http://www.google.com/search?domains=网站地址&sitesearch=网站地址&q=" wq;  

window.open(link); }  

</script> 

<input type="text" name="wq"/><input type="submit" onclick="javascript:googlesearch()" value="Google 搜索" /> 

<!--Google站内搜索结束--> 

 

<!--Baidu站内搜索开始--> 

<script language="javascript"> 

function baidusearch () {  

var wd=document.getElementsByName("wd")[0].value;  

var link="http://www.baidu.com/s?si=网站地址&cl=3&ct=2097152&tn=baidulocal&word=" wd;  

window.open(link); }  

</script> 

<input type="text" name="wd"/><input type="submit" onclick="javascript:baidusearch()" value="Baidu 搜索" /> 

<!--Baidu站内搜索结束-->  

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蓝图

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值