您现在的位置:中国下载站学院中心网络编程CC++教程 → 文章列表

Google搜索客户端API for C/C++

作者:佚名  来源:不详  发布时间:2007-4-3 23:36:47   

减小字体 增大字体

 
 

本文示例源代码下载

  Google 网站上提供了goole search client api for Java和for dot.net的版本,大家可以参考.

  For C/C++的版本特点如下

  内置XML解析器.

  内置gbk/utf-8编码/解码器(包含GBK编码表)

  采用Pure C编写,采用标准C接口.

  支持http代理.

  用户需要在http://api.google.com/createkey申请key

  演示程序中的key是一个网友给我的,仅供测试用,演示程序中的代理可能连接不上,由于没有设置超时,可能处于等待状态(sorry.....)

  函数中各个参数的意义和http://www.google.com/apis/reference.html的说明一样,对此不作过多的介绍.

  建议在此基础上开发二次应用,如封装成COM,但不得对作者提供的api进行反编译.

  如需转载,请注明原作者,谢谢合作.欢迎交流.

  函数接口

/************************************************************************/
      /*google search client api for c/c++*/
      /*By littlestar,2003,TRS Open Lab*/
/************************************************************************/
//go http://www.google.com/apis/reference.html for more information
/*start primitive data types*/
#ifdef _SOAP_TYPES
typedef char * xsd__string;
typedef int xsd__int;
struct xsd__base64Binary
{
  unsigned char *__ptr;
  int __size;
};
typedef bool xsd__boolean;
typedef double xsd__double;
/*end primitive data types*/
struct DirectoryCategoryArray
{
  struct typens__DirectoryCategory * __ptr;
  int __size;
  int __offset;
};
struct typens__ResultElement
{
  xsd__string summary;
  xsd__string URL;
  xsd__string snippet;
  xsd__string title;
  xsd__string cachedSize;
  xsd__boolean relatedInformationPresent;
  xsd__string hostName;
  struct typens__DirectoryCategory * directoryCategory;
  xsd__string directoryTitle;
};
struct typens__doGoogleSearchResponse
{
  struct typens__GoogleSearchResult * _return_;
};
struct typens__DirectoryCategory
{
  xsd__string fullViewableName;
  xsd__string specialEncoding;
};
struct typens__GoogleSearchResult
{
  xsd__boolean documentFiltering;
  xsd__string searchComments;
  xsd__int estimatedTotalResultsCount;
  xsd__boolean estimateIsExact;
  struct ResultElementArray * resultElements;
  xsd__string searchQuery;
  xsd__int startIndex;
  xsd__int endIndex;
  xsd__string searchTips;
  struct DirectoryCategoryArray * directoryCategories;
  xsd__double searchTime;
};
struct ResultElementArray
{
  struct typens__ResultElement * __ptr;
  int __size;
  int __offset;
};
struct typens__doSpellingSuggestionResponse
{
  xsd__string _return_;
};
struct typens__doGetCachedPageResponse
{
  struct xsd__base64Binary * _return_;
};
#endif
//建立Soap连接
extern "C" int _stdcall CreateSoapSession(void **SoapSessionHandle,char
*strServerAdd,char *key);
//设置代理服务器,支持http代理.
extern "C" int _stdcall SetSoapProxy(void *SoapSessionHandle,char
*strProxyHost,int ProxyPort);
//页面检索
extern "C" int _stdcall doGoogleSearch(void *SoapSessionHandle, xsd__string
q, xsd__int start, xsd__int maxResults, xsd__boolean filter,
xsd__string restrict_, xsd__boolean safeSearch, xsd__string lr,
xsd__string ie, xsd__string oe, struct typens__doGoogleSearchResponse *
out);
//取得google服务器上的缓存页面
extern "C" int _stdcall doGetCachedPage(void *SoapSessionHandle,
xsd__string url, struct typens__doGetCachedPageResponse * out );
//拼写检查
extern "C" int _stdcall doSpellingSuggestion(void *SoapSessionHandle,
xsd__string phrase, struct typens__doSpellingSuggestionResponse * out );
//取得SOAP错误消息
extern "C" char* _stdcall GetSoapErrorMessage(void *SoapSessionHandle);
//释放SOAP缓存.
extern "C" int _stdcall FreeSoapCache(void *SoapSessionHandle);
//释放Soap连接
extern "C" int _stdcall FreeSoapSession(void **SoapSessionHandle);
google 提供的wsdl文件<?xml version="1.0"?>
<!-- WSDL description of the Google Web APIs.
   The Google Web APIs are in beta release. All interfaces are subject to
   change as we refine and extend our APIs. Please see the terms of use
   for more information. -->
<!-- Revision 2002-08-16 -->
<definitions name="GoogleSearch"
       targetNamespace="urn:GoogleSearch"
       xmlns:typens="urn:GoogleSearch"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
       xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
       xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
       xmlns="http://schemas.xmlsoap.org/wsdl/">
 <!-- Types for search - result elements, directory categories -->
 <types>
  <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="urn:GoogleSearch">
      
   <xsd:complexType name="GoogleSearchResult">
    <xsd:all>
     <xsd:element name="documentFiltering"     
type="xsd:boolean"/>
     <xsd:element name="searchComments"       
type="xsd:string"/>
     <xsd:element name="estimatedTotalResultsCount" type="xsd:int"/>
     <xsd:element name="estimateIsExact"      
type="xsd:boolean"/>
     <xsd:element name="resultElements"       
type="typens:ResultElementArray"/>
     <xsd:element name="searchQuery"        
type="xsd:string"/>
     <xsd:element name="startIndex"         type="xsd:int"/>
     <xsd:element name="endIndex"          type="xsd:int"/>
     <xsd:element name="searchTips"         
type="xsd:string"/>
     <xsd:element name="directoryCategories"    
type="typens:DirectoryCategoryArray"/>
     <xsd:element name="searchTime"         
type="xsd:double"/>
    </xsd:all>
   </xsd:complexType>
   <xsd:complexType name="ResultElement">
    <xsd:all>
     <xsd:element name="summary" type="xsd:string"/>
     <xsd:element name="URL" type="xsd:string"/>
     <xsd:element name="snippet" type="xsd:string"/>
     <xsd:element name="title" type="xsd:string"/>
     <xsd:element name="cachedSize" type="xsd:string"/>
     <xsd:element name="relatedInformationPresent"
type="xsd:boolean"/>
     <xsd:element name="hostName" type="xsd:string"/>
     <xsd:element name="directoryCategory"
type="typens:DirectoryCategory"/>
     <xsd:element name="directoryTitle" type="xsd:string"/>

在百度中搜索更多Google搜索客户端API for C/C++相关网页 转贴于:中国下载站

  • 上一篇文章:用 C 实现 WebService
  • 下一篇文章:C++如何处理内联虚函数
  • 阅读统计:[]
  • 中国下载站】【设为主页】【收藏本页】【打印本文】【回到顶部】【关闭此页

    相关文章
    文章评论(评论内容只代表网友观点,与本站立场无关!)

    用户名: 查看更多评论

    分 值:100分 85分 70分 55分 40分 25分 10分 0分

    内 容:

             (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码


    设为首页 - 关于我们 - 广告服务 - 网站地图 - 加入收藏 - 网站声明 - 网站帮助 - 友情链接

    • Copyright (C) 2006-2008 www.cndownz.com All Rights Reserved.
      中国下载站 版权所有. 粤ICP备05141802号. 对本站有任何建议、意见或投诉,请来信:cndownzcom@yahoo.com.cn.
      喜欢中国下载站(cndownz.com),请把中国下载站(cndownz.com)告诉你QQ上的5位好友,多谢支持!