文本版|topic 高级搜索
   名人堂 帮助 论坛制度 意见反馈 | 首页 博客 周新贴 招聘 专题 新闻
RSS 底部
 
社区导航: 专家门诊   网络技术   操作系统   数据库   程序设计   系统应用   考试认证   CIO及信息化   站长交流   综合交流   下载基地  51CTO产品服务 设为首页 | 收藏本站
51CTO技术论坛» Java » 使用google api 连接google       [ 打印]  [ 订阅]  [ 收藏]  [ 推荐给朋友]   [ 本帖文本页]

论坛跳转:
     
标题: [转载] 使用google api 连接google  ( 查看:106  回复:0 )   
 
amyhang
技术员  点击可查看详细



帖子 87
精华 0
无忧币 2576
积分 305
阅读权限 30
注册日期 2008-4-12
最后登录 2008-7-21 离线

[查看资料]  [发短消息]  [Blog
       
发表于:2008-5-9 08:28   标题:使用google api 连接google
上一帖 |
Caution:需要google的公钥的。

PHP 代码:

import java.io.*;
import com.google.soap.search.*; // 这是 googleapi.jar

public class SearchGoogle  
{

public static void main(String[] args)
{
if (args.length != 1)  
{
System.err.println("Usage: java SearchGoogle LicenseKey 查询字符串 ");
System.exit(1);
}
String clientKey ="your public key";
String queryString = args[0];

System.out.println(" 查询字符串 = " + queryString);

// 产生查找对象,设定输出编码 (big5)
GoogleSearch s = new GoogleSearch();
s.setKey(clientKey);
//s.setOutputEncoding("big5");
s.setProxyHost("202.119.24.35");
s.setProxyPort(8080);
s.setProxyUserName("name");
s.setProxyPassword("password");

try  
{
s.setQueryString(queryString);
GoogleSearchResult r = s.doSearch();
System.out.println(" 查找结果 :");
System.out.println("======================");
System.out.println(r.toString());
}  
catch (com.google.soap.search.GoogleSearchFault e)  
{
System.out.println(" 查找失败 ");
}
}
}  

E:\temp>java SearchGoogle 信息检索
查询字符串 = 信息检索
查找结果 :
======================
{
TM = 0.212145
Q = "信息检索"
CT = ""
TT = ""
CATs =
{

}
Start Index = 1
End Index = 10
Estimated Total Results Number = 47200
Document Filtering = true
Estimate Correct = false
Rs =
{

[
URL = "http://www.enviroinfo.org.cn/"
Title = ""
Snippet = ""
Directory Category = {SE="", FVN=""}
Directory Title = ""
Summary = ""
Cached Size = ""
Related information present = true
Host Name = ""
],

[
URL = "http://www.patent.com.cn/"
Title = "中国专利信息网--China Patent Searching Information"
Snippet = ""
Directory Category = {SE="GB2312", FVN="Top/World/Chinese_Simplified/地区/亚洲
/中国/商业与经济"}
Directory Title = "中国专利信息网"
Summary = "集专利检索、专利知识、专利法律法规、项目推广、高技术传播、广告服务
等功..."
Cached Size = "3k"
Related information present = true
Host Name = ""
],

[
URL = "http://www.yippee.com.cn/"
Title = "新司南New Yippee!-朝鲜迷搜索引擎Korea Fan Search Engine"
Snippet = "朝鲜迷搜索引擎. 登录 中文英文 日文 朝文 加入
收藏夹 捉死链. 中
朝网[武汉市朝鲜迷工作室] 镜
像. ... "
Directory Category = {SE="", FVN=""}
Directory Title = ""
Summary = ""
Cached Size = "18k"
Related information present = true
Host Name = ""
],

[
URL = "http://www.sipo.gov.cn/sipo/zljs/default.htm"
Title = "专利检索"
Snippet = "全部专利 发明专利 实用新型 外观设计 帮 助 ... "
Directory Category = {SE="", FVN=""}
Directory Title = ""
Summary = ""
Cached Size = "32k"
Related information present = true
Host Name = ""
],

[
URL = "http://www.medinfofree.com/"
Title = "免费医药信息检索"
Snippet = " ... 2003.7.2.更新. 来信标明主题否则被删除. 77级校友会

校园浏览. 版权所有,任意复制 ?免费医药信息检
索. "
Directory Category = {SE="", FVN=""}
Directory Title = ""
Summary = ""
Cached Size = "9k"
Related information present = true
Host Name = ""
],

[
URL = "http://search.hzic.edu.cn/"
Title = ""
Snippet = ""
Directory Category = {SE="", FVN=""}
Directory Title = ""
Summary = ""
Cached Size = ""
Related information present = true
Host Name = ""
],

[
URL = "http://www.qsjournal.com.cn/qs/20030716/GB/20-QS-XXJS.htm"
Title = "当期杂志"
Snippet = " ... [文化大观]: 加快湖南文化产业发展. [红旗论坛]: 从抗击 非典看社会主义制度的优越性. 人民日报. . 信息检索. 期
号: ... "
Directory Category = {SE="", FVN=""}
Directory Title = ""
Summary = ""
Cached Size = "11k"
Related information present = true
Host Name = ""
],

[
URL = "http://www.qsjournal.com.cn/qs/20030701/GB/18-QS-XXJS.htm"
Title = "当期杂志"
Snippet = " ... [科教天地]: 大力发展循环经济. 人民日报. . 信息检索. 期 号:
文章标题: 文章内容: 作 者: 栏 目: 日 期: 从 至 (格式:yyy
ymmdd). ... "
Directory Category = {SE="", FVN=""}
Directory Title = ""
Summary = ""
Cached Size = "11k"
Related information present = true
Host Name = "www.qsjournal.com.cn"
],

[
URL = "http://www.bufotanine.com/search/"
Title = "搜索引擎:中国癌症信息库"
Snippet = "抗癌新药 多媒体频道 乳腺癌专题 专业资源 信息检索

癌症预防 科学治癌 健康杂志 癌症SOS, 将本页推荐给好
友. ... "
Directory Category = {SE="", FVN=""}
Directory Title = ""
Summary = ""
Cached Size = "11k"
Related information present = true
Host Name = ""
],

[
URL = "http://www.newone.com.cn/search.jsp"
Title = "Newone Search"
Snippet = "预约开户, 网上招聘, 信息检索, 开放式基金交易, 邮件咨
询,
English, 牛网营业厅, 首页. 交易. 新闻. 市场. 研究. 产品. 社
区. 我们
. ... "
Directory Category = {SE="", FVN=""}
Directory Title = ""
Summary = ""
Cached Size = "21k"
Related information present = true
Host Name = ""
]
}
}



网络工程师到底该不该去考CCIE认证?
2008-5-9 08:281楼
[ 顶部 ]
     
论坛跳转:  

| | |

标记已读 · 删除论坛Cookies · 文本版 · WAP
 
| 诚征版主 | 版主堂 | 意见建议 | 大史记 | 论坛地图
Copyright©2005-2008 51CTO.COM  Powered by Discuz!
本论坛言论纯属发布者个人意见,不代表51CTO网站立场!如有疑义,请与管理员联系。
京ICP备05051492号