Skip to content

谷歌CSE自定义搜索-阿里云函数计算FC版

License

Notifications You must be signed in to change notification settings

dsttl3/GoogleCSE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoogleCSE

谷歌CSE自定义搜索

如何Google自定义搜索 + 阿里云函数计算 实现完美使用Google搜索
优点:
自定义搜索结果
国内网络无障碍访问
无广告

获取代码

// github 仓库地址
https://github.com/dsttl3/GoogleCSE

需修改\src\main\resources目录下的config.setting配置文件,如下

[cse]
# 搜索引擎ID (如果需要自己定制,可以在 https://cse.google.com 申请)
cx = 007765593562555407508:qxj7yrxd00a 
# url 主域名 (改成自己的域名)
url = https://google.dsttl3.cn/
# css链接
cssurl = https://dsttl3.cn/css/st.css
# logo图片
logourl = https://dsttl3.cn/img/dstt.png
# 百度统计ID (改成自己的)
bdid = a177f39aa76e5026c3a549f48d7b8a0e

如何获取自己的搜索引擎ID

https://cse.google.com/ 自定义自己的搜索引擎(访问该网站需要��正常访问Google的网络环境)
添加一个自己的搜索引擎
cse1.png

获取自己的搜索引擎 ID
cse2.png

创建阿里函数计算

登录到阿里云函数计算fc控制台 https://fcnext.console.aliyun.com/overview
创建服务一个新服务,地区要选择香港或者能正常访问Google的地区
alifc1.png

日志功能是需要付费的,这里需要关闭掉
alifc2.png

创建服务一个函数,运行环境选择Java8或者Java11
alifc3.png

上传代码,选择自己编译好的jar包
alifc4.png

配置函数
alifc5.png

配置 请求处理程序(函数入口) GetHtml::handleRequest 如果需要返回json格式,填写 GetJson::handleRequest
alifc6.png

配置好以后就可以配置自定义域名了

配置自定义域名

https://fcnext.console.aliyun.com/cn-hongkong/domains
这里地区同样是选择香港
alifc7.png

路由配置根据刚才创建的函数选择
alifc8.png

配置完成后通过http://域名/?sou=关键词访问,例https://google.dsttl3.cn/?sou=dsttl3

演示

通过https://google.dsttl3.cn/?sou=搜索的关键词进行搜索,示例https://google.dsttl3.cn/?sou=dsttl3
image.png

配置Chrome地址栏搜索和右键快捷搜索

首先打开chrome的设置,找到搜索引擎选项

image.png

选择管理搜索引擎和网站搜索

image.png

网站搜索模块下添加

image.png

image.png

最后设置成默认搜索

image.png