查看: 55|回复: 0

如何创建你的百Google度!!(实现双搜索引擎页面)

[复制链接]

0

主题

0

回帖

0

积分

积极分子

金币
0
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2012-5-23
发表于 2025-11-18 21:08:00 | 显示全部楼层 |阅读模式

创建双搜索引擎页面

百Google度的网站被封了,但!!!这不影响我们创建属于自己的双搜索引擎页面!

提前准备
找到你想添加的俩个搜索引擎对应的URI 和 它预先定义用于存储搜索关键词的参数名

打开你想要的搜索引擎的网页,在当前搜索引擎里输入“关键词”,点击搜索,然后观察上面的网址,一般“?”前出现的是对应的【URI】,“&”的后面到你输入的“关键词”前,是当前搜索引擎预定义的【参数名】

一些示例(e.g.):

  • 【360】https://www.so.com/s q
  • 【搜狐】https://search.sohu.com/s keyword
  • 【百度】https://www.baidu.com/s wd
  • 【Microsoft Bing】https://cn.bing.com/search q
    等等等等等~~~

下面代码统一以【Microsoft Bing】和【360】为例:

Part.One HTML结构实现

点击查看代码
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>双搜索引擎</title>
</head>
<body>
    <h1>Bing & 360 双搜索</h1>
    
    <!-- 用户输入区域 -->
    <input id="searchInput" />
    <input type="button" onclick="performSearch()" value="双搜"/>
    
    <!-- 搜索引擎表单 -->
    <form name="bingForm" action="https://cn.bing.com/search" target="leftFrame">
        <input type="hidden" name="q"/>         
    </form>
    <form name="soForm" action="https://www.so.com/s" target="rightFrame">
        <input type="hidden" name="q"/>
    </form>
    
    <!-- 结果展示区域 -->
    <iframe name="leftFrame" style="height: 1000px;width: 50%;"></iframe>
    <iframe name="rightFrame" style="height: 1000px;width: 50%;"></iframe>
</body>
</html>

Part.Two JavaScript交互逻辑

点击查看代码
<script type="text/javascript">
function performSearch(){
    // 获取用户输入的搜索词
    var searchText = document.getElementById("searchInput").value;
    
    // 将搜索词赋给两个表单的隐藏字段
    document.bingForm.q.value = searchText;
    document.soForm.q.value = searchText;
    
    // 同时提交两个表单
    document.bingForm.submit();
    document.soForm.submit();
}
</script>

回顾:设计思路

分析页面的核心需求:
1. 一个输入框接收用户搜索词
2. 一个触发搜索的按钮
3. 两个隐藏表单分别对应不同搜索引擎
4. 两个iframe展示搜索结果

OK那么我们就完成了百Google度的创建了!撒花!!



来源:https://www.cnblogs.com/angelicaYQ/p/19234460
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部