• λ我爱Aspx >> Asp.Net >> 使用Google的Web Service
  • 使用Google的Web Service

  • :aspxer  Դ:internet  :2007-5-28 20:36:38  ؼ:web,google
  • <searchQuery xsi:type="xsd:string">

    "science fiction"

    </searchQuery>

    </return>

    </ns1:doGoogleSearchResponse>

    </SOAP-ENV:Body>

    </SOAP-ENV:Envelope>

    四、使用Google API

    Google为了提高开发人员的开发效率,提供了一套基于Java的API,用于直接访问Google服务器。该API包装了Google的Web Service,使用起来比Web Service更加方便。该API 包主要包括如下几个类:

    GoogleSearch :该类封装了对于Google服务器的访问,支持搜索和缓存(cache)功能。

    GoogleSearchDirectoryCategory :表示Google中的一个分类目录

    GoogleSearchFault :该类为Exception的一个子类,用于表示API使用的错误。

    GoogleSearchResult :该类封装了搜索的结果。

    GoogleSearchResultElement:该类表示搜索结果中的每一条记录。

    如下是一个例子的源代码,用于一个简单查询,查询请求为”world Cup”,查询的帐号为”123456789”。该例子将把查询结果打印出来。如果用户需要近一步解析查询结果,可以使用GoogleSearchResult和GoogleSearchResultElement类。

    import com.google.soap.search.*;

    import java.io.*;

    public class GoogleAPITest {

    Ҷƪл˵?
  • һƪ利用正则表达式将html网页数据变成Web Service
    һƪ新浪短信Web Service