分享
 
 
 

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

王朝vc·作者佚名  2006-01-17
窄屏简体版  字體: |||超大  

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

作者:littlestar(TRS Open Lab)

下载示例工程

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"/

</xsd:all

</xsd:complexType

<xsd:complexType name="ResultElementArray"

<xsd:complexContent

<xsd:restriction base="soapenc:Array"

<xsd:attribute ref="soapenc:arrayType"

wsdl:arrayType="typens:ResultElement[]"/

</xsd:restriction

</xsd:complexContent

</xsd:complexType

<xsd:complexType name="DirectoryCategoryArray"

<xsd:complexContent

<xsd:restriction base="soapenc:Array"

<xsd:attribute ref="soapenc:arrayType"

wsdl:arrayType="typens:DirectoryCategory[]"/

</xsd:restriction

</xsd:complexContent

</xsd:complexType

<xsd:complexType name="DirectoryCategory"

<xsd:all

<xsd:element name="fullViewableName" type="xsd:string"/

<xsd:element name="specialEncoding" type="xsd:string"/

</xsd:all

</xsd:complexType

</xsd:schema

</types

<!-- Messages for Google Web APIs - cached page, search, spelling. --

<message name="doGetCachedPage"

<part name="key" type="xsd:string"/

<part name="url" type="xsd:string"/

</message

<message name="doGetCachedPageResponse"

<part name="return" type="xsd:base64Binary"/

</message

<message name="doSpellingSuggestion"

<part name="key" type="xsd:string"/

<part name="phrase" type="xsd:string"/

</message

<message name="doSpellingSuggestionResponse"

<part name="return" type="xsd:string"/

</message

<!-- note, ie and oe are ignored by server; all traffic is UTF-8. --

<message name="doGoogleSearch"

<part name="key" type="xsd:string"/

<part name="q" type="xsd:string"/

<part name="start" type="xsd:int"/

<part name="maxResults" type="xsd:int"/

<part name="filter" type="xsd:boolean"/

<part name="restrict" type="xsd:string"/

<part name="safeSearch" type="xsd:boolean"/

<part name="lr" type="xsd:string"/

<part name="ie" type="xsd:string"/

<part name="oe" type="xsd:string"/

</message

<message name="doGoogleSearchResponse"

<part name="return" type="typens:GoogleSearchResult"/

</message

<!-- Port for Google Web APIs, "GoogleSearch" --

<portType name="GoogleSearchPort"

<operation name="doGetCachedPage"

<input message="typens:doGetCachedPage"/

<output message="typens:doGetCachedPageResponse"/

</operation

<operation name="doSpellingSuggestion"

<input message="typens:doSpellingSuggestion"/

<output message="typens:doSpellingSuggestionResponse"/

</operation

<operation name="doGoogleSearch"

<input message="typens:doGoogleSearch"/

<output message="typens:doGoogleSearchResponse"/

</operation

</portType

<!-- Binding for Google Web APIs - RPC, SOAP over HTTP --

<binding name="GoogleSearchBinding" type="typens:GoogleSearchPort"

<soap:binding style="rpc"

transport="http://schemas.xmlsoap.org/soap/http"/

<operation name="doGetCachedPage"

<soap:operation soapAction="urn:GoogleSearchAction"/

<input

<soap:body use="encoded"

namespace="urn:GoogleSearch"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/

</input

<output

<soap:body use="encoded"

namespace="urn:GoogleSearch"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/

</output

</operation

<operation name="doSpellingSuggestion"

<soap:operation soapAction="urn:GoogleSearchAction"/

<input

<soap:body use="encoded"

namespace="urn:GoogleSearch"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/

</input

<output

<soap:body use="encoded"

namespace="urn:GoogleSearch"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/

</output

</operation

<operation name="doGoogleSearch"

<soap:operation soapAction="urn:GoogleSearchAction"/

<input

<soap:body use="encoded"

namespace="urn:GoogleSearch"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/

</input

<output

<soap:body use="encoded"

namespace="urn:GoogleSearch"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/

</output

</operation

</binding

<!-- Endpoint for Google Web APIs --

<service name="GoogleSearchService"

<port name="GoogleSearchPort" binding="typens:GoogleSearchBinding"

<soap:address location="http://api.google.com/search/beta2"/

</port

</service

</definitions

(全文完)

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有